Revision 48c07635 ui/static/synnefo.js
b/ui/static/synnefo.js | ||
---|---|---|
3090 | 3090 |
|
3091 | 3091 |
function show_invitations() { |
3092 | 3092 |
|
3093 |
function display_resend_success(msg) { |
|
3094 |
clear_resend_messages(); |
|
3095 |
$("#invsent .message.success").text(msg).show(); |
|
3093 |
var invsent_per_page = INVITATIONS_PER_PAGE; |
|
3094 |
function handle_pagination(p) { |
|
3095 |
show_sent_page(p, invsent_per_page); |
|
3096 |
return false; |
|
3096 | 3097 |
} |
3098 |
|
|
3099 |
function show_sent_page(i, per_page) { |
|
3100 |
$("#invsent ul li").hide(); |
|
3101 |
start = i * per_page; |
|
3102 |
end = start + per_page; |
|
3097 | 3103 |
|
3098 |
function display_resend_error(msg) { |
|
3099 |
clear_resend_messages(); |
|
3100 |
$("#invsent .message.errormsg").text(msg).show(); |
|
3104 |
var i = start; |
|
3105 |
while(i < start + per_page) { |
|
3106 |
$($("#invsent ul li")[i]).show(); |
|
3107 |
i++; |
|
3108 |
} |
|
3109 |
} |
|
3110 |
|
|
3111 |
function paginate_sent() { |
|
3112 |
var per_page = invsent_per_page; |
|
3113 |
var total = $(".invitations #invsent ul li").length; |
|
3114 |
$(".invitations .pages").pagination(total, {callback: handle_pagination, items_per_page: per_page}); |
|
3115 |
show_sent_page(0, per_page); |
|
3116 |
} |
|
3117 |
|
|
3118 |
function display_resend_msg(msg, cls) { |
|
3119 |
el = $("<span class='resend-msg "+cls+"'>"+msg+"</span>"); |
|
3120 |
|
|
3121 |
(function(el) { |
|
3122 |
var element = el; |
|
3123 |
window.setTimeout(function(){ |
|
3124 |
element.fadeOut(1000).delay(2000).remove(); |
|
3125 |
}, 4000); |
|
3126 |
})(el) |
|
3127 |
$("#invsent .message.success").append(el).show(); |
|
3101 | 3128 |
} |
3102 | 3129 |
|
3103 | 3130 |
// clear resent messages |
... | ... | |
3125 | 3152 |
type: "POST", |
3126 | 3153 |
url : "/invitations/resend", |
3127 | 3154 |
data : {invid : id}, |
3155 |
invid: id, |
|
3128 | 3156 |
success: function(msg) { |
3129 |
display_resend_success("Invitation has been resent"); |
|
3157 |
inv_email = $(".resend-invitation#inv-" + this.invid).parent().find(".email").text(); |
|
3158 |
display_resend_msg("Invitation to <em>'"+inv_email+"'</em> has been resent", "success-msg"); |
|
3130 | 3159 |
child.attr('src', '/static/resend.png'); |
3131 | 3160 |
}, |
3132 | 3161 |
error : function(xhr, status, error) { |
3133 |
display_resend_error("Something seems to have gone wrong. " +
|
|
3134 |
"Please try again in a few minutes.");
|
|
3162 |
inv_email = $(".resend-invitation#inv-" + this.invid).parent().find(".email").text();
|
|
3163 |
display_resend_msg("Invitation to <em>'"+inv_email+"'</em> failed to send", "error-msg");
|
|
3135 | 3164 |
child.attr('src', '/static/resend.png'); |
3136 | 3165 |
} |
3137 | 3166 |
}); |
... | ... | |
3139 | 3168 |
} |
3140 | 3169 |
|
3141 | 3170 |
handle_invitations = function(el) { |
3142 |
|
|
3171 |
|
|
3172 |
if ($("div.invitations").length > 1) { |
|
3173 |
$($("div.invitations")[0]).remove(); |
|
3174 |
} |
|
3143 | 3175 |
// proper class to identify the overlay block |
3144 | 3176 |
el.addClass("invitations"); |
3145 | 3177 |
|
... | ... | |
3167 | 3199 |
$(".invitations .submit").show(); |
3168 | 3200 |
$(".invitations #fieldheaders").show(); |
3169 | 3201 |
$(".invitations #fields").show(); |
3202 |
$("#fields input[name=name_1]").focus(); |
|
3170 | 3203 |
|
3171 | 3204 |
// reset title |
3172 | 3205 |
$("#notification-box .header-box").html(""); |
3173 | 3206 |
$("#notification-box .header-box").html(window.INVITATIONS_TITLE + " " + $($(".invitations-left")[0]).text()); |
3174 |
|
|
3207 |
|
|
3175 | 3208 |
// resend buttons |
3176 | 3209 |
register_invitation_resends(); |
3177 | 3210 |
clear_resend_messages(); |
3178 | 3211 |
|
3212 |
paginate_sent(); |
|
3213 |
|
|
3179 | 3214 |
// handle form submit |
3180 | 3215 |
form.submit(function(evn){ |
3181 | 3216 |
evn.preventDefault(); |
Also available in: Unified diff