~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Brad Crittenden
  • Date: 2011-04-14 16:37:22 UTC
  • mto: This revision was merged to the branch mainline in revision 12856.
  • Revision ID: bac@canonical.com-20110414163722-aju8ropmdb3w2fd0
Handle the lack of a mute_link without falling over.  Fix lint, spelling, and poor html markup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
252
252
function get_mute_subscription() {
253
253
    setup_client_and_bug();
254
254
    var mute_link = Y.one('.menu-link-mute_subscription');
 
255
    if (Y.Lang.isNull(mute_link)) {
 
256
        return null;
 
257
    }
255
258
    var mute_subscription = new Y.lp.bugs.subscriber.Subscription({
256
259
        link: mute_link,
257
260
        spinner: Y.one('#mute-unmute-spinner'),
279
282
    }
280
283
 
281
284
    var mute_subscription = get_mute_subscription();
 
285
    if (Y.Lang.isNull(mute_subscription)) {
 
286
        return;
 
287
    }
282
288
    var mute_link = mute_subscription.get('link');
283
289
    var parent_node = mute_link.get('parentNode');
284
290
    mute_link.addClass('js-action');
665
671
        // If the user has a mute on the bug we add some UI polish to
666
672
        // the subscription overlay.
667
673
        var mute_subscription = get_mute_subscription();
668
 
        if(mute_subscription.get('is_muted')) {
 
674
        if (!Y.Lang.isNull(mute_subscription) &&
 
675
            mute_subscription.get('is_muted')) {
669
676
            Y.lp.bugs.bug_subscription.set_up_bug_notification_level_field();
670
677
        }
671
678
        subscription_overlay.show();
1208
1215
    var link = subscription.get('link');
1209
1216
    var link_parent = link.get('parentNode');
1210
1217
    var mute_subscription = get_mute_subscription();
 
1218
    var is_muted = (!Y.Lang.isNull(mute_subscription) &&
 
1219
                    mute_subscription.get('is_muted'));
1211
1220
    if (link_parent.hasClass('subscribed-false') &&
1212
1221
        link_parent.hasClass('dup-subscribed-false') &&
1213
 
        !mute_subscription.get('is_muted')) {
 
1222
        !is_muted) {
1214
1223
        // The user isn't subscribed or muted, so subscribe them.
1215
1224
        subscription.set(
1216
1225
            'bug_notification_level',
1229
1238
            on: {
1230
1239
                success: function(lp_subscription) {
1231
1240
                    subscription.enable_spinner('Updating subscription...');
1232
 
                    if (mute_subscription.get('is_muted')) {
 
1241
                    if (is_muted) {
1233
1242
                        mute_subscription.enable_spinner('Unmuting...');
1234
1243
                    }
1235
1244
                    lp_subscription.set(
1246
1255
                                    node: link_parent
1247
1256
                                    });
1248
1257
                                anim.run();
1249
 
                                if (mute_subscription.get('is_muted')) {
 
1258
                                if (is_muted) {
1250
1259
                                    mute_subscription.set('is_muted', false);
1251
1260
                                    mute_subscription.disable_spinner(
1252
1261
                                        "Mute bug mail");
1272
1281
        lp_client.get(subscription_url, config);
1273
1282
    } else {
1274
1283
        // The user is already subscribed and wants to unsubscribe.
1275
 
        if (mute_subscription.get('is_muted')) {
 
1284
        if (is_muted) {
1276
1285
            unmute_current_user(mute_subscription);
1277
1286
        } else {
1278
1287
            unsubscribe_current_user(subscription);