~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

merge in changes from parent branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
696
696
    subscribe_only_closed: 'select-only-direct-subscription-lifecycle',
697
697
    unsubscribe: 'remove-direct-subscription',
698
698
    unsubscribe_with_warning: 'remove-direct-subscription-with-warning'
699
 
}
 
699
};
700
700
 
701
701
/**
702
702
 * Get direct subscription information.
913
913
}
914
914
 
915
915
function unsubscribe_action() {
916
 
    return make_action('remove-direct-subscription')
 
916
    return make_action(action_ids.unsubscribe)
917
917
        .append(
918
918
            make_action_link(
919
919
                'unsubscribe from this bug',
921
921
}
922
922
 
923
923
function unsubscribe_with_warning_action() {
924
 
    return make_action('remove-direct-subscription-with-warning')
 
924
    return make_action(action_ids.unsubscribe_with_warning)
925
925
        .append(
926
926
            make_action_link( // XXX Fix text.
927
927
                'You can also unsubscribe from this bug.  However, you also have other subscriptions to this bug that may send you email once you have unsubscribed.',
928
928
                 'remove', 'unsubscribe', {}));
929
929
}
930
930
 
 
931
/**
 
932
 * Makes links for subscribing actions.
 
933
 */
931
934
function make_subscribe_link(text, level) {
932
935
    return make_action_link(
933
936
        text,
937
940
    );
938
941
}
939
942
 
 
943
/**
 
944
 * Makes links for all kinds of actions.
 
945
 */
940
946
function make_action_link(text, sprite_class, method_name, parameters) {
941
947
    var node = Y.Node.create('<a/>')
942
948
            .set('text', text)
975
981
        }
976
982
    );
977
983
    return node;
 
984
 
 
985
function border_box(title, content_div) {
 
986
    return Y.Node.create('<div/>')
 
987
        .addClass('hidden')
 
988
        .setStyle('border', '1px solid #ddd')
 
989
        .setStyle('padding', '0 1em 1em 1em')
 
990
        .append(Y.Node.create('<span/>')
 
991
            .setStyle('backgroundColor', '#fff')
 
992
            .setStyle('float', 'left')
 
993
            .setStyle('marginTop', '-0.6em')
 
994
            .setStyle('padding', '0 1ex')
 
995
            .set('text', title))
 
996
        .append(content_div
 
997
            .setStyle('clear', 'both')
 
998
            .setStyle('padding', '1em 0 0 1em'));
978
999
}
979
1000
 
980
1001
/**
986
1007
 *     personal subscriptions (if any).
987
1008
 */
988
1009
function get_direct_description_node(info) {
 
1010
    var i;
989
1011
    var direct_info = get_direct_subscription_information(info);
 
1012
    var less_email_title = 'If you don\'t want to receive emails about '+
 
1013
        'this bug you can';
 
1014
    var more_email_title = 'If you want to receive more emails about '+
 
1015
        'this bug you can';
990
1016
    var direct_node = Y.Node.create('<div/>')
991
1017
        .set('id', 'direct-subscription')
992
1018
        .set('text', direct_info.reason)
993
1019
        // Make border box for actions that reduce email.
994
 
        .append(Y.Node.create('<div/>')
995
 
            .addClass('reductions')
996
 
            .addClass('hidden')
997
 
            .setStyle('border', '1px solid #ddd')
998
 
            .setStyle('padding', '0 1em 1em 1em')
999
 
            .append(Y.Node.create('<span/>')
1000
 
                .setStyle('backgroundColor', '#fff')
1001
 
                .setStyle('float', 'left')
1002
 
                .setStyle('marginTop', '-0.6em')
1003
 
                .setStyle('padding', '0 1ex')
1004
 
                .set('text', 'If you don\'t want to receive emails about '+
1005
 
                    'this bug you can'))
1006
 
            .append(Y.Node.create('<div/>')
1007
 
                .setStyle('clear', 'both')
1008
 
                .setStyle('padding', '1em 0 0 1em')
 
1020
        .append(border_box(less_email_title, Y.Node.create('<div/>')
1009
1021
                .append(mute_action())
1010
1022
                .append(subscribe_only_metadata_action())
1011
1023
                .append(subscribe_only_closed_action())
1012
 
                .append(unsubscribe_action())))
 
1024
                .append(unsubscribe_action()))
 
1025
            .addClass('reductions'))
1013
1026
        // Make border box for actions that increase email.
1014
 
        .append(Y.Node.create('<div/>')
1015
 
            .addClass('increases')
1016
 
            .addClass('hidden')
1017
 
            .setStyle('border', '1px solid #ddd')
1018
 
            .setStyle('padding', '0 1em 1em 1em')
1019
 
            .append(Y.Node.create('<span/>')
1020
 
                .setStyle('backgroundColor', '#fff')
1021
 
                .setStyle('float', 'left')
1022
 
                .setStyle('marginTop', '-0.6em')
1023
 
                .setStyle('padding', '0 1ex')
1024
 
                .set('text', 'If you want to receive more emails about '+
1025
 
                    'this bug you can'))
1026
 
            .append(Y.Node.create('<div/>')
1027
 
                .setStyle('clear', 'both')
1028
 
                .setStyle('padding', '1em 0 0 1em')
 
1027
        .append(border_box(more_email_title, Y.Node.create('<div/>')
1029
1028
                .append(unmute_action())
1030
1029
                .append(subscribe_all_action())
1031
1030
                .append(subscribe_metadata_action())
1032
 
                .append(subscribe_closed_action())))
 
1031
                .append(subscribe_closed_action()))
 
1032
            .addClass('increases'))
1033
1033
        // Add the unsubscribe action for when they have other subscriptions.
1034
1034
        .append(unsubscribe_with_warning_action());
1035
1035
 
1037
1037
        // If there are any actions the user can take, unhide the actions box
1038
1038
        // and then unhide the specific actions that they should see.
1039
1039
        direct_node.one('.reductions').removeClass('hidden');
1040
 
        var i;
1041
1040
        for (i=0; i<direct_info.reductions.length; i++) {
1042
1041
            direct_node.one('#'+direct_info.reductions[i])
1043
1042
                .removeClass('hidden');
1048
1047
        // If there are any actions the user can take, unhide the actions box
1049
1048
        // and then unhide the specific actions that they should see.
1050
1049
        direct_node.one('.increases').removeClass('hidden');
1051
 
        var i;
1052
1050
        for (i=0; i<direct_info.increases.length; i++) {
1053
1051
            direct_node.one('#'+direct_info.increases[i])
1054
1052
                .removeClass('hidden');