~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/javascript/filebug_dupefinder.js

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-07-17 23:09:32 UTC
  • mfrom: (13452.1.1 revert-lots)
  • Revision ID: launchpad@pqm.canonical.com-20110717230932-sp6yro99is2077fx
[r=wgrant][rollback=13421] Revert r13421 and r13438 (already
 partially reverted in r13443 and restored in r13445). Fix for DSP:+index
 expanders has not yet landed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
}
78
78
 
79
79
/**
 
80
 * Collapse the details for a bug and set its expander arrow to
 
81
 * 'collapsed'
 
82
 * @param expander The expander to collapse.
 
83
 */
 
84
function collapse_bug_details(expander) {
 
85
    var bug_details_div = get_details_div(expander);
 
86
    var anim = Y.lazr.effects.slide_in(bug_details_div);
 
87
    anim.run();
 
88
 
 
89
    expander.set(SRC, EXPANDER_COLLAPSED);
 
90
}
 
91
 
 
92
/**
80
93
 * Show the bug reporting form and collapse all bug details forms.
81
94
 */
82
95
function show_bug_reporting_form() {
185
198
        duplicate_div.set(INNER_HTML, response.responseText);
186
199
 
187
200
        bug_already_reported_expanders = Y.all(
188
 
            'td.bug-already-reported-expander');
 
201
            'img.bug-already-reported-expander');
189
202
        if (bug_already_reported_expanders.size() > 0) {
190
203
            // If there are duplicates shown, set up the JavaScript of
191
204
            // the duplicates that have been returned.
357
370
 
358
371
namespace.setup_dupes = function() {
359
372
    bug_already_reported_expanders = Y.all(
360
 
        'td.bug-already-reported-expander');
 
373
        'img.bug-already-reported-expander');
361
374
    var bug_reporting_form = Y.one('#bug-reporting-form');
362
375
 
363
376
    if (bug_already_reported_expanders.size() > 0) {
 
377
        // Collapse all the details divs, since we don't want them
 
378
        // expanded first up.
 
379
        Y.each(Y.all('div.duplicate-details'), function(div) {
 
380
            collapse_bug_details(div);
 
381
        });
 
382
 
364
383
        // Set up the onclick handlers for the expanders.
365
384
        Y.each(Y.all('.similar-bug'), function(row) {
366
385
            var bug_details_div = row.one('div.duplicate-details');
 
386
            var image = row.one('img.bug-already-reported-expander');
367
387
            var bug_title_link = row.one('.duplicate-bug-link');
 
388
            var view_bug_link = row.one('.view-bug-link');
 
389
 
 
390
            // Shut down the default action for the link and mark it
 
391
            // as a JS'd link. We do this as it's simpler than
 
392
            // trying to find all the bits of the row that we want
 
393
            // to make clickable.
368
394
            bug_title_link.addClass('js-action');
369
 
            var view_bug_link = row.one('.view-bug-link');
370
 
            var expander = new Y.lp.app.widgets.expander.Expander(
371
 
                row, bug_details_div);
372
 
            expander.setUp();
 
395
            bug_title_link.on('click', function(e) {
 
396
                e.preventDefault();
 
397
            });
373
398
 
374
399
            // The "view this bug" link shouldn't trigger the
375
400
            // collapsible, so we stop the event from propagating.
385
410
                e.stopPropagation();
386
411
            });
387
412
 
388
 
            // Preventing default behaviour stops the browser from
389
 
            // emitting the focus event here as well.
390
 
            bug_title_link.on('click', function(e) {
391
 
                // Stop the click event from being emitted down
392
 
                // to the container node.
393
 
                if (this.focused_expansion === true &&
394
 
                    expander._animation.get('running')) {
395
 
                    e.stopPropagation();
396
 
                }
397
 
                this.focused_expansion = false;
398
 
                e.preventDefault();
399
 
            });
400
 
 
401
413
            // Set up the on focus handler for the link so that
402
414
            // tabbing will expand the different bugs.
403
415
            bug_title_link.on('focus', function(e) {
404
 
                if (!expander.isExpanded()) {
405
 
                    this.focused_expansion = true;
406
 
                    expander.render(true);
 
416
                if (!bug_details_div.hasClass('lazr-opened')) {
 
417
                    var anim = Y.lazr.effects.slide_out(bug_details_div);
 
418
                    anim.run();
 
419
 
 
420
                    image.set(SRC, EXPANDER_EXPANDED);
407
421
 
408
422
                    // If the bug reporting form is shown, hide it.
409
423
                    if (bug_reporting_form.getStyle(DISPLAY) == BLOCK) {
411
425
                    }
412
426
                }
413
427
            });
 
428
 
 
429
            row.on('click', function(e) {
 
430
                if (bug_details_div.hasClass('lazr-opened')) {
 
431
                    collapse_bug_details(image);
 
432
                } else {
 
433
                    var anim = Y.lazr.effects.slide_out(bug_details_div);
 
434
                    anim.run();
 
435
 
 
436
                    image.set(SRC, EXPANDER_EXPANDED);
 
437
                }
 
438
            });
414
439
        });
415
440
 
416
441
        // Hide the bug reporting form.
478
503
 
479
504
}, "0.1", {"requires": [
480
505
    "base", "io", "oop", "node", "event", "json", "lazr.formoverlay",
481
 
    "lazr.effects", "lp.app.widgets.expander"]});
 
506
    "lazr.effects"]});