~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/static/javascript/diff.js

  • Committer: Michael Hudson
  • Date: 2009-03-04 22:27:37 UTC
  • Revision ID: michael.hudson@canonical.com-20090304222737-681htpm64dbfjk1m
remove tabs from changelog.pt

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
  var removed = [];
42
42
  function clear_bufs(before) {
43
43
    if (!added.length && !removed.length) return;
 
44
    Y.log('hai');
44
45
    var common = Math.min(added.length, removed.length);
45
46
    for (var i = 0; i < common; i++) {
46
47
      var a = added[i];
87
88
 
88
89
function toggle_unified_sbs(event) {
89
90
  event.preventDefault();
90
 
  var pts = Y.all(".pseudotable");
91
91
  if (unified) {
92
 
    pts && pts.each(make_sbs);
 
92
    Y.all(".pseudotable").each(make_sbs);
93
93
    unified = false;
94
94
    Y.get("#toggle_unified_sbs").set('innerHTML', "Show unified diffs");
95
95
  }
96
96
  else {
97
 
    pts && pts.each(make_unified);
 
97
    Y.all(".pseudotable").each(make_unified);
98
98
    unified = true;
99
99
    Y.get("#toggle_unified_sbs").set('innerHTML', "Show diffs side-by-side");
100
100
  }
104
104
 
105
105
function toggle_expand_all_revisionview(action)
106
106
{
107
 
  var diffs = Y.all('.diff');
 
107
  var diffs = Y.all('.diffBox');
108
108
  if (diffs == null) return;
109
109
  diffs.each(
110
110
    function(item, i)
143
143
  '#collapse_all a'
144
144
);
145
145
 
146
 
function node_process(node) {
147
 
  if (!unified) {
148
 
    node.get('children').filter('.pseudotable').each(make_sbs);
149
 
  }
150
 
}
151
 
 
152
 
function zoom_to_diff (path) {
153
 
  var collapsable = Y.get('#' + path_to_id[path]).collapsable;
154
 
  if (!collapsable.is_open) {
155
 
    collapsable.open(
156
 
      function () {
157
 
        window.location.hash = '#' + path;
158
 
      });
159
 
  }
160
 
}
161
 
 
162
146
Y.on(
163
147
  "domready", function () {
164
148
    Y.all(".show_if_js").removeClass("show_if_js");
165
 
    if (!specific_path) {
166
 
      Y.all("#list-files a").on(
167
 
        'click',
168
 
        function (e) {
169
 
          e.preventDefault();
170
 
          var path = decodeURIComponent(e.target.get('href').split('#')[1]);
171
 
          window.location.hash = '#' + path;
172
 
          zoom_to_diff(path);
173
 
        });
174
 
    }
175
 
    var diffs = Y.all('.diff');
 
149
    var diffs = Y.all('.diffBox');
176
150
    if (diffs == null) return;
177
151
    diffs.each(
178
152
      function(item, i)
179
153
      {
180
 
        var source_url = null;
181
 
        if (!specific_path)
182
 
          source_url = global_path + '+filediff/' + link_data[item.get('id')];
183
 
        item.query('.the-link').on(
184
 
          'click',
185
 
          function(e) {
186
 
            e.preventDefault();
187
 
            collapsable.toggle();
188
 
          });
189
 
        var collapsable = new Collapsable(
190
 
          {
191
 
            expand_icon: item.query('.expand_diff'),
192
 
            open_node: item.query('.diffinfo'),
193
 
            close_node: null,
194
 
            source: source_url,
195
 
            is_open: specific_path != null,
196
 
            loading: item.query('.loading'),
197
 
            node_process: node_process
198
 
          });
199
 
       item.collapsable=collapsable;
200
 
       });
201
 
    if (window.location.hash && !specific_path) {
202
 
      zoom_to_diff(window.location.hash.substring(1));
203
 
    }
 
154
        var item_slide = item.next('.diffinfo');
 
155
        var expand_icon = item.query( '.expand_diff' );
 
156
        var collapsable = new Collapsable(item_slide, expand_icon, [], [], true);
 
157
        item.query('.expand_diff').on('click', function(){collapsable.toggle();});
 
158
        item.collapsable=collapsable;
 
159
      });
204
160
  });