~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/javascript/structural-subscription.js

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
324
324
    add_input_validator(overlay, overlay_id, 'tags', get_error_for_tags_list);
325
325
}
326
326
 
 
327
var ellipsis_supported =
 
328
    typeof document.createElement('span').style.textOverflow === 'string';
 
329
var is_gecko = navigator.product === 'Gecko';
 
330
// If we're running on a Gecko-based browser (like Firefox) and it doesn't
 
331
// have text-overflow then use the ellipsis hack.
 
332
var using_ellipsis_hack = is_gecko && !ellipsis_supported;
 
333
 
327
334
/**
328
335
 * Populate the overlay element with the contents of the add/edit form.
329
336
 */
336
343
    if (Y.Lang.isValue(namespace._add_subscription_overlay)) {
337
344
        namespace._add_subscription_overlay.destroy();
338
345
    }
 
346
    var header = Y.Node.create('<h2/>')
 
347
            .set('id', 'subscription-overlay-title')
 
348
            .set('text', 'Add a mail subscription '+
 
349
                'for '+LP.cache.context.title+' bugs')
 
350
            .setStyle('display', 'block')
 
351
            .setStyle('overflow', 'hidden')
 
352
            .setStyle('textOverflow', 'ellipsis')
 
353
            .setStyle('whiteSpace', 'nowrap')
 
354
            .setStyle('width', '21em');
339
355
    // Create the overlay.
340
356
    namespace._add_subscription_overlay = new Y.lazr.FormOverlay({
341
 
        headerContent:
342
 
            '<h2 id="subscription-overlay-title">Add a mail subscription '+
343
 
            'for '+LP.cache.context.title + ' bugs</h2>',
 
357
        headerContent: header,
344
358
        form_content: Y.one(overlay_id),
345
359
        visible: false,
346
360
        form_submit_button: submit_button,
364
378
    if (side_portlets) {
365
379
        Y.one('#subscription-overlay-title').scrollIntoView();
366
380
    }
 
381
    if (using_ellipsis_hack) {
 
382
        // Look away.
 
383
        var header_text = header.get('text');
 
384
        var i;
 
385
        for (i=header_text.length; i--; i > 0) {
 
386
            if (header.get('scrollWidth') <= header.get('offsetWidth')) {
 
387
                if (i !== header_text.length) {
 
388
                    header.addClass('force-ellipsis');
 
389
                }
 
390
                break;
 
391
            }
 
392
            header.set('text', header_text.substring(0, i));
 
393
        }
 
394
    }
367
395
    setup_overlay_validators(namespace._add_subscription_overlay, overlay_id);
368
396
    // Prevent cruft from hanging around upon closing.
369
397
    // For some reason, clicking on the cancel button doesn't fire a cancel