/* Minified: jquery.mailingActivityLog.js, widgets.AddEditIncomingMailboxForm.js */
jQuery.fn.mailingActivityLog=function(s){var settings=jQuery.extend({load_more_url:null,entries:null,entries_per_load:30,total_entries:0},s);return this.pagedObjectsList({load_more_url:settings.load_more_url,items:settings.entries,items_per_load:settings.entries_per_load,total_items:settings.total_entries,list_items_are:"tr",list_item_attributes:{"class":"mailing_activity_log"},columns:{icon:"",info:App.lang("Message"),from:App.lang("From"),to:App.lang("To"),created_on:App.lang("Logged On"),options:App.lang("Options")},on_add_item:function(item){var log_entry=$(this);log_entry.append('<td class="icon"></td><td class="info"></td><td class="from"></td><td class="to"></td><td class="created_on"></td><td class="options"></td>');$("<img>").attr("src",item.icon_url).appendTo(log_entry.find("td.icon"));log_entry.find("td.info").append(item.name);if(item.from){$("<a></a>").attr("href",item.from["urls"]["view"]).text(item.from["short_display_name"]).appendTo(log_entry.find("td.from"))}if(item.to){$("<a></a>").attr("href",item.to["urls"]["view"]).text(item.to["short_display_name"]).appendTo(log_entry.find("td.to"))}log_entry.find("td.created_on").text(item.created_on["formatted"]);if(item.has_details){$('<a href="'+item.urls["view"]+'" class="view_details" title="'+App.lang("View Details")+'"><img src="'+App.Wireframe.Utils.imageUrl("/icons/12x12/preview.png","environment")+'" /></a>').flyout({title:App.lang("Details")}).appendTo(log_entry.find("td.options"))}}})};
App.widgets.AddEditIncomingMailboxForm=function(){return{init:function(wrapper_id,test_mailbox_connection_url){var mailbox_form=$("#"+wrapper_id);var result_container=$("#test_connection .test_connection_results",mailbox_form);var result_image=$("img:eq(0)",result_container);var result_output=$("span:eq(0)",result_container);$("#test_connection button").click(function(){result_container.removeClass("connection_ok connection_error");result_image.attr("src",App.Wireframe.Utils.indicatorUrl());result_output.text(App.lang("Testing mailbox..."));$.ajax({type:"post",url:App.extendUrl(test_mailbox_connection_url,{async:1}),data:{"mailbox[host]":mailbox_form.find("#hostName").val(),"mailbox[server_type]":mailbox_form.find("#mailboxType input:checked").val(),"mailbox[security]":mailbox_form.find("#mailboxSecurity input:checked").val(),"mailbox[port]":mailbox_form.find("#mailboxPort").val(),"mailbox[mailbox]":mailbox_form.find("#mailboxName").val(),"mailbox[username]":mailbox_form.find("#username").val(),"mailbox[password]":mailbox_form.find("#password").val(),submitted:"submitted"},success:function(response){result_output.text(App.lang("Connected to mailbox. You have :num unread messages",{num:response}));result_image.attr("src",App.Wireframe.Utils.indicatorUrl("ok"));result_container.removeClass("connection_error");result_container.addClass("connection_ok")},error:function(response){var message=App.Wireframe.Utils.responseToErrorMessage(response);result_output.text(message);result_image.attr("src",App.Wireframe.Utils.indicatorUrl("error"));result_container.removeClass("connection_ok");result_container.addClass("connection_error")}});return false});var type_change_handler=function(){var port_field=$("#mailboxPort");if($(this).val()=="POP3"){if(port_field.val()==""||port_field.val()=="143"){port_field.val("110").parent().highlightFade()}}else{if(port_field.val()==""||port_field.val()=="110"){port_field.val("143").parent().highlightFade()}}};$("#mailboxType").click(type_change_handler).change(type_change_handler)}}}();App.widgets.RenderProjectElement=function(){return{init:function(wrapper_id,filter_id,action_class_name,to_url){var action_form_box=$("#"+wrapper_id);var project_select_box=$("#"+wrapper_id+" .project_box");var insert_into_div=$("#"+wrapper_id+" .render_project_settings");if(insert_into_div.length==0){return false}project_select_box.change(function(){renderProjectElement()});renderProjectElement();function renderProjectElement(){var project_id=project_select_box.val();var incoming_mail_object_name=$(".working_box #incoming_mail_action_name").val();$.ajax({url:App.extendUrl(to_url,{async:1}),type:"post",data:{submitted:"submitted",project_id:project_id,filter_id:filter_id,action_class_name:action_class_name},success:function(response){insert_into_div.html(response)},error:function(error){}})}set_notify_sender();function set_notify_sender(){var create_public_page=action_form_box.find("#create_public_page");if(action_form_box.find("#notify_sender:checked").val()==1){create_public_page.removeAttr("disabled")}else{create_public_page.attr("disabled","disabled")}}action_form_box.delegate("#notify_sender","click",function(){set_notify_sender()});set_priority();function set_priority(){var task_priority=action_form_box.find("#task_priority");if(action_form_box.find(".use_message_priority:checked").val()=="use_custom_priority"){task_priority.removeAttr("disabled")}else{task_priority.attr("disabled","disabled")}}action_form_box.delegate(".use_message_priority","click",function(){set_priority()})}}}();
