Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- mailbox
- - load
- - messages
- - load
- - select_all
- - refresh
- - move_to_trash_multi
- - pagination
- - new
- - create
- - recipient_remove
- - send
- - message
- - load
- - move_to_trash
- - attachment_download
- - attachments_download
- - move_attachments_to_organizer
- - forward
- - reply
- */
- $(function() {
- var mailbox = {
- loader: function() {
- $("#mailbox_ajax").html('<div class="overlay text-center" style="margin-top:20%"><i class="fa fa-refresh fa-spin fa-5x"></i></div>');
- },
- messages: {
- load: function() {
- mailbox.loader();
- var search_query = $("input[name=folder_search_query]").val(); // is search query?
- $(".mailbox_folder").removeClass('active'); // remove folder active from all sidebar folders
- var type_name = '';
- var type_parameter = '';
- if( Object.prototype.toString.call(type) === '[object Array]' ) {
- if ("type" in type)
- var type_name = type.type;
- if ("parameter" in type)
- var type_parameter = type.parameter;
- }
- else
- {
- type_name = type;
- }
- var folder = $("input[name=folder_active]").val();
- var folder_time = $("input[name=folder_time]").val();
- var limit = $("input[name=folder_limit]").val();
- var offset = $("input[name=folder_offset]").val();
- var type = $("input[name=folder_type]").val();
- var type_parameter = $("input[name=folder_type_parameter]").val();
- var type_parameter_1 = $("input[name=folder_type_parameter_1]").val();
- var unseen = $("input[name=folder_unseen]").val();
- var attachments = $("input[name=folder_attachments]").val();
- ajax({action:'mailbox_messages',mailbox_id : mailbox_id,folder:folder,folder_time:folder_time,type:type,type_parameter:type_parameter,type_parameter_1:type_parameter_1,limit:limit,offset:offset,'title' : $('[data-folder="'+folder+'"]').attr('data-title'),unseen:unseen,attachments:attachments,search_query:search_query},function(data) {
- $("#mailbox_folders").html(data.html_folders);
- $("#mailbox_ajax").html(data.html);
- $("[data-pagination=page_previus]").prop('disabled',false);
- $("[data-pagination=page_next]").prop('disabled',false);
- if (data.statistic.unseen > 0)
- $('[data-folder="'+folder+'"]').find('.nr').html(data.statistic.unseen).removeClass('hidden').fadeIn();
- $("input[name=folder_active]").val(folder);
- $("[data-folder='"+folder+"']").parent().addClass('active');
- $("[data-pagination='total']").html(data.mailbox_data.messages_nr_total);
- var pagination_from = data.mailbox_data.offset;
- var pagination_to = parseInt(data.mailbox_data.offset) + parseInt(data.mailbox_data.limit);
- if (pagination_from <= 0)
- {
- pagination_from = 0;
- $("[data-pagination=page_previus]").prop('disabled',true);
- }
- if (pagination_to == 0)
- pagination_to = data.mailbox_data.limit;
- if (pagination_from > pagination_to)
- pagination_from = 1;
- pagination_from ++;
- if (pagination_to >= data.mailbox_data.messages_nr_total)
- {
- pagination_to = data.mailbox_data.messages_nr_total;
- $("[data-pagination=page_next]").prop('disabled',true);
- }
- $("[data-pagination='from']").html(pagination_from);
- $("[data-pagination='to']").html(pagination_to);
- $('iframe').each(function() {
- $height = $(this).height();
- //alert($height);
- });
- });
- },
- select_all: function($status) {
- $(':checkbox').each(function() {
- if ($status == true)
- $(this).prop('checked',true);
- else
- $(this).prop('checked',false);
- });
- },
- refresh: function(mailbox_id,folder)
- {
- mailbox.messages.load(mailbox_id,folder,'all');
- },
- move_to_trash_multi: function(mailbox_id,folder,uids)
- {
- var checked_messages_nr = $('input[name="mailbox[]"]:checked').length;
- var checked_messages = $('input[name="mailbox[]"]:checked');
- if (checked_messages_nr == 0)
- modal_make('warning','<div class="text-center lead">Označite zapise, ki jih želite izbrisati.</div>');
- if (checked_messages_nr > 0)
- {
- modal_make('trash_multi');
- $(document.body).on('click','#modal_confirm',function(e) {
- var message_uids = selected_checkboxes_value("mailbox[]");
- mailbox.loader();
- ajax({'action':'messages_move_to_trash','mailbox_id' : mailbox_id, 'folder' : folder,'message_uids' : message_uids},function(data) {
- modal_close();
- mailbox.messages.load(mailbox_id,folder,'all');
- });
- });
- }
- },
- pagination: function($type) {
- limit = parseInt($("input[name=folder_limit").val());
- if ($type == 'next')
- {
- $nr = parseInt($("[data-pagination=total]").html());
- $max = $nr / $("input[name=folder_limit").val();
- $max = Math.ceil($max);
- $val = parseInt($("input[name=folder_offset]").val()) + limit;
- $("input[name=folder_offset]").val($val);
- $to = parseInt($("[data-pagination=from]").html()) + parseInt(limit);
- $from = parseInt($("[data-pagination=to]").html()) + parseInt(limit);
- $("[data-pagination=from]").html($to);
- $("[data-pagination=to]").html($from);
- mailbox.messages.load(mailbox_id,$("input[name=folder_active]").val(),'all',$to,limit);
- }
- if ($type == 'previus')
- {
- $offset = parseInt($("input[name=folder_offset]").val()) - limit;
- if ($offset < 0)
- $offset = 0;
- $("input[name=folder_offset]").val($offset);
- $from = parseInt($("[data-pagination=from]").html()) - parseInt($("input[name=folder_limit").val());
- if ($from < 0)
- $from = 0;
- $to = parseInt($("[data-pagination=to]").html()) - parseInt($("input[name=folder_limit").val());
- if ($to < 1) // can not be 0
- $to = $("input[name=folder_limit]").val();
- $("[data-pagination=from]").html($from);
- $("[data-pagination=to]").html($to);
- mailbox.messages.load(mailbox_id,$("input[name=folder_active]").val(),'all',$to,limit);
- }
- }
- },
- new: {
- // create, new, reply
- create: function(mailbox_id,action_type,message_uid) {
- // submit on shift + enter
- $(document.body).keypress(function(e) {
- if (e.keyCode == 13 && e.shiftKey) {
- mailbox.new.send();
- }
- });
- // create proces
- hash = window.location.hash.substr(1);
- hash = hash_array(hash);
- console.log(hash);
- if (hash[1] !== 'create')
- hash_set('create');
- if (hash[3])
- {
- ajax({action:'create_recipient_add',recipient:hash[3]});
- }
- mailbox.loader();
- console.log(action_type);
- if (typeof action_type =='undefined')
- {
- var action_type = 'create';
- }
- ajax({action:'create','action_type':action_type,'mailbox_id' : mailbox_id,message_uid : message_uid},function(data) {
- $("#mailbox_ajax").html(data.html);
- $("#mailbox_folders").html(data.html_folders);
- $toolbar = [
- ['Format','FontSize','TextColor'],
- ['btgrid','media_embed','embed','embedbase'],
- ['Undo','Redo','RemoveFormat','Bold','Italic','Underline','Strike','NumberedList','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Link','Unlink','Image','Table','Source'],
- ];
- if (mobile)
- {
- $toolbar = [
- ['Undo','Redo','RemoveFormat','Bold','Italic','Underline','NumberedList','Link','Unlink','Image','Table','Source'],
- ]
- }
- CKEDITOR.inline('email_content',{
- extraPlugins: 'autogrow,pastebase64,maximize',
- enableOnReadonly: true,
- enterMode: CKEDITOR.ENTER_BR,
- uiColor: '#ffffff',
- startupFocus: false,
- toolbar : $toolbar,
- });
- // on create - on change textarea update template
- CKEDITOR.instances["email_content"].on('change', function() {
- $last_save = $("input[name=last_save]").val();
- $time_diff = $.now() - $last_save;
- if ($time_diff > 5000)
- {
- $("input[name=last_save]").val($.now());
- ajax({mailbox_id : mailbox_id,action:'create_save_content',subject:$("input[name=subject]").val(),content:this.getData()},function(data) {
- });
- }
- });
- // when in create mode show recipient fields which have valid email address
- $('.recipient_email').each(function() {
- if (valid_email($(this).val()))
- $(".recipient_nr_"+$(this).attr('mailbox-recipient-nr')).removeClass('hidden');
- });
- });
- },
- recipient_remove: function(recipient) {
- preloader();
- ajax({'action':'create_recipient_remove','recipient' : recipient},function(data) {
- $("#recipient_list").html(data.html);
- });
- },
- send: function() {
- error = false;
- // collect data - recipients type and recipients (select + input)
- recipients = [];
- recipients_type = [];
- $('.recipient_email').each(function() {
- if (valid_email($(this).val()))
- recipients.push($(this).val());
- });
- i = 0;
- $("select.recipient_receive_type").each(function() {
- i++;
- if (valid_email($("[mailbox-recipient-nr="+i+"]").val()))
- recipients_type.push($(this).val());
- });
- // collect data - subject
- subject = $("input[name=subject]").val();
- // collect data - content
- var item = CKEDITOR.instances["email_content"];
- var body = item.getData();
- ajax({action:'send_2',mailbox_id:mailbox_id,recipients_type:recipients_type,recipients:recipients,subject:subject,body:body,reply_to:$("input[name=reply_to]").val()},function(data) {
- $("input[name=subject]").attr('style','font-size:1.5em; color:black; padding-left:0.3em; border-bottom:2px solid green !important');
- if (typeof data.error.body != 'undefined') {
- $("textarea[name=email_content]").focus();
- $(".error_body").fadeIn(10).fadeOut(5000);
- }
- if (typeof data.error.subject != 'undefined') {
- $("input[name=subject]").focus();
- $("input[name=subject]").attr('style','font-size:1.5em; color:black; padding-left:0.3em; border-bottom:2px solid red !important');
- }
- if (typeof data.error.recipient != 'undefined') {
- $("input[name=email_recipient_1]").focus();
- $("input[name=email_recipient_1]").attr('style','border-bottom:2px solid red !important');
- }
- if (data.sent == true)
- {
- $("#html_creating").addClass('hidden');
- $("#html_sent").removeClass('hidden');
- $html = $("#mailbox_ajax").html();
- $html = $html.replace('{sent_datetime}',data.sent_datetime);
- $html = $html.replace('{sent_recipient}',data.sent_recipient);
- $html = $html.replace('{sent_subject}',data.sent_subject);
- $html = $html.replace('{sent_message}',data.sent_message);
- $("#mailbox_ajax").html($html);
- }
- });
- }
- },
- message: {
- load: function(mailbox_id,folder,uid) {
- mailbox.loader();
- ajax({'action':'message_view','mailbox_id' : mailbox_id, 'folder' : folder,'message_uid' : uid},function(data) {
- hash_set('message/' + uid);
- $("#mailbox_ajax").html(data.html);
- });
- },
- move_to_trash: function(mailbox_id,folder,uid,next_uid = false)
- {
- modal_make('trash');
- $(document.body).on('click','#modal_confirm',function(e) {
- ajax({'action':'message_move_to_trash','mailbox_id' : mailbox_id, 'folder' : folder,'message_uid' : uid},function(data) {
- modal_close();
- if (next_uid == false)
- {
- if (ba == 'view')
- {
- $("#tr_"+uid).fadeOut();
- $("#tr_"+uid+'_preview').fadeOut();
- }
- else
- {
- mailbox.loader();
- mailbox.messages.load();
- }
- }
- else
- {
- mailbox.message.load(mailbox_id,folder,next_uid);
- }
- });
- });
- },
- attachment_download: function(mailbox_id,message_uid,attachment_id)
- {
- window.location = '/mailbox/'+s2+'/attachment/'+message_uid+'/'+attachment_id;
- },
- attachments_download: function(mailbox_id,message_uid,attachment_id)
- {
- window.location = '/mailbox/'+s2+'/attachments_download/'+message_uid;
- },
- move_attachments_to_organizer: function(mailbox_id,message_uid)
- {
- ajax({action:'move_attachments_to_organizer',mailbox_id:mailbox_id,message_uid:message_uid},function(data) {
- select2_organizer();
- });
- },
- forward: function(mailbox_id,message_uid)
- {
- console.log("forward");
- mailbox.new.create(mailbox_id,'forward',message_uid);
- },
- reply: function(mailbox_id,message_uid)
- {
- mailbox.new.create(mailbox_id,'reply',message_uid);
- console.log("reply");
- }
- }
- };
- /*********************************************************************************************************************************************************************************
- MAILBOX CALLERS
- *********************************************************************************************************************************************************************************/
- uri = uri();
- console.log(uri[1]);
- switch (uri[1])
- {
- default:
- mailbox.messages.load();
- break;
- case 'inbox':
- if (typeof uri[2] == 'undefined')
- $("input[name=folder_active]").val('inbox');
- if (typeof uri[2] != 'undefined')
- $("input[name=folder_active]").val(uri[2]);
- $("input[name=folder_type]").val('all');
- $("input[name=folder_type_parameter]").val('');
- $("input[name=folder_unseen]").val('');
- $("input[name=folder_attachments]").val('');
- mailbox.messages.load();
- break;
- case 'create':
- mailbox.new.create(mailbox_id);
- break;
- case 'message':
- mailbox.message.load(mailbox_id,$(this).attr('data-folder'),uri[2]);
- break;
- case 'from':
- $("input[name=folder_type]").val('from');
- $("input[name=folder_type_parameter]").val(uri[2]);
- mailbox.messages.load();
- break;
- case 'status':
- $("input[name=folder_type]").val('status');
- $("input[name=folder_type_parameter]").val(uri[2]);
- if (uri[2] == 'all')
- {
- $("input[name=folder_type]").val('all');
- $("input[name=folder_type_parameter]").val('');
- }
- mailbox.messages.load();
- break;
- case 'contacts':
- ajax({action:'mailbox_contacts',mailbox_id:mailbox_id,html_replace:'#mailbox_ajax'},function(data) {});
- break;
- }
- // load box message - folder click - inbox, sent, etc..
- $(document.body).on('click','[data-modul=box_messages]',function(e) {
- hash_set('inbox/' + $(this).attr('data-folder'));
- $("input[name=folder_active]").val($(this).attr('data-folder'));
- $("input[name=folder_type]").val('all');
- $("input[name=folder_type_parameter]").val('');
- $("input[name=folder_unseen]").val('');
- $("input[name=folder_attachments]").val('');
- if ($("input[name=folder_time]").val() == $(this).attr('data-time'))
- $("input[name=folder_time]").val(''); // reset if set same time
- else
- $("input[name=folder_time]").val($(this).attr('data-time'));
- mailbox.messages.load();
- });
- /* MAILBOX VIEW */
- // button - create new message
- $(document.body).on('click','[data-modul=message_create]',function(e) {
- mailbox.new.create(mailbox_id);
- });
- // trash multi selected items
- $(document.body).on('click','[data-modul=trash_multi]',function(e) {
- var uids = false;
- mailbox.messages.move_to_trash_multi(mailbox_id,$("input[name=folder_active]").val(),uids);
- });
- $(document.body).on('keypress','input[name=mailbox_search]', function(e){
- if(e.which === 13){
- $("input[name=folder_search_query]").val($("input[name=mailbox_search]").val());
- mailbox.messages.load(mailbox_id,$("input[name=folder_active]").val(),'all');
- e.preventDefault();
- }
- });
- // click on message to see details of message
- $(document.body).on('click','[data-modul=message_view]',function(e) {
- if (!window.event.ctrlKey) {
- // $("input[name=folder_type]").val('from');
- // $("input[name=folder_type_parameter]").val($(this).attr('data-from'));
- mailbox.message.load(mailbox_id,$(this).attr('data-folder'),$(this).attr('data-uid'));
- }
- });
- // show only unread messages
- $(document.body).on('click','[data-modul=show_only_unseen]',function(e) {
- var val = $("input[name=folder_unseen]").val();
- if (val == 1)
- $("input[name=folder_unseen]").val(0);
- else
- $("input[name=folder_unseen]").val(1);
- mailbox.messages.load();
- });
- // show only messages with attachments
- $(document.body).on('click','[data-modul=show_only_with_attachment]',function(e) {
- var val = $("input[name=folder_attachments]").val();
- if (val == 1)
- $("input[name=folder_attachments]").val(0);
- else
- $("input[name=folder_attachments]").val(1);
- mailbox.messages.load();
- });
- // show messages by status - open, answered, closed, urgent
- $(document.body).on('click','[data-modul=show_by_status]',function(e) {
- if (!window.event.ctrlKey) {
- $("input[name=folder_type]").val('status');
- if ($(this).attr('data-status') !== 'reload')
- {
- $("input[name=folder_type_parameter]").val($(this).attr('data-status'));
- }
- if ($(this).attr('data-status') == 'all')
- {
- $("input[name=folder_type]").val('all');
- $("input[name=folder_type_parameter]").val('');
- }
- mailbox.messages.load();
- }
- });
- // message load from
- $(document.body).on('click','[data-modul=messages_from]',function(e) {
- if (!window.event.ctrlKey) {
- $("input[name=folder_type]").val('from');
- $("input[name=folder_type_parameter]").val($(this).attr('data-from'));
- mailbox.messages.load();
- }
- });
- // select all messages
- $(document.body).on('click','[data-mailbox=select_all]',function(e) {
- mailbox.messages.select_all($(this).is(':checked'));
- });
- // pagination next
- $(document.body).on('click','[data-pagination=page_next]',function(e) {
- mailbox.messages.pagination('next');
- e.preventDefault();
- });
- // pagination previus
- $(document.body).on('click','[data-pagination=page_previus]',function(e) {
- mailbox.messages.pagination('previus');
- e.preventDefault();
- });
- $(document.body).on('click','[data-modul=load_message]',function(e) {
- $message_uid = $(this).attr('data-ID');
- mailbox.message.load(mailbox_id,$("input[name=folder_active]").val(),$message_uid);
- e.preventDefault();
- })
- // message status
- $(document.body).on('click','[data-modul=status]',function(e) {
- var message_uid = $(this).attr('data-uid');
- var email = $(this).attr('data-email');
- var status = $(this).attr('data-status');
- ajax({action : 'message_status',mailbox_id : mailbox_id, folder : $("input[name=folder_active]").val(), message_uid : message_uid,email:email,status:status},function(data) {});
- });
- // message status newsletter
- $(document.body).on('change','select[name=select_status]',function(e) {
- $val = $('select[name=select_status] option:selected').val();
- if ($val == 'newsletter')
- {
- $("#mailbox_newsletter_options").removeClass('hidden');
- }
- else
- {
- $("#mailbox_newsletter_options").addClass('hidden');
- }
- });
- // MAILBOX MESSAGE (DETAILS)
- // message move to trash
- $(document.body).on('click','[data-modul=message_move_to_trash]',function(e) {
- if ($(this).attr('data-from') == 'view')
- {
- // get uid from view
- $next_uid = false;
- $uid = $(this).attr('data-uid');
- }
- else
- {
- // get uid from -> when message is open
- $uid = $("#html_message").attr('data-uid');
- $next_uid = $(this).attr('data-nextuid');
- }
- mailbox.message.move_to_trash(mailbox_id,$("#html_message").attr('data-folder'),$uid,$next_uid);
- });
- // attachment download
- $(document.body).on('click','[data-mailbox=attachment]',function(e) {
- var attachment_id = $(this).attr('attachment-id');
- var message_uid = $(this).attr('message-uid');
- mailbox.message.attachment_download(mailbox_id,message_uid,attachment_id);
- });
- // attachments download
- $(document.body).on('click','[data-mailbox=download_attachments]',function(e) {
- var message_uid = $(this).attr('message-uid');
- mailbox.message.attachments_download(mailbox_id,message_uid);
- });
- // attachments move to organizer
- $(document.body).on('click','[data-mailbox=move_attachments_to_organizer]',function(e) {
- var message_uid = $(this).attr('message-uid');
- mailbox.message.move_attachments_to_organizer(mailbox_id,message_uid);
- });
- $(document.body).on('click','[data-mailbox=forward]',function(e) {
- var message_uid = $(this).attr('message-uid');
- mailbox.message.forward(mailbox_id,message_uid);
- });
- $(document.body).on('click','[data-mailbox=reply]',function(e) {
- var message_uid = $(this).attr('message-uid');
- mailbox.message.reply(mailbox_id,message_uid);
- });
- // CREATE MESSAGE
- // predefined content
- $(document.body).on('click','[data-create=predefined_content]',function(e) {
- ajax({action:'mailbox_create_predefined_messages',mailbox_id:mailbox_id},function(data) {
- });
- });
- // mailbox create new message modal, select predefined document
- $(document.body).on('click','.modal_dropdown_select_document',function(e) {
- ajax({action:'mailbox_create_predefined_messages_get_document',mailbox_id:mailbox_id,document_id:$(this).attr('data-value')},function(data) {
- if ($("input[name=subject]").val() == '')
- $("input[name=subject]").val(data.document.title);
- var item = CKEDITOR.instances["email_content"];
- var body = item.setData(data.document.content);
- CKEDITOR.instances['email_content'].setData(data.document.content);
- });
- });
- // message open - chevron left - open messages - show messages and hide message
- $(document.body).on('click','[data-modul=show_messages]',function(e) {
- mailbox.messages.load();
- });
- // send message
- $(document.body).on('click','[data-create=send]',function(e) {
- preloader('show');
- mailbox.new.send();
- preloader('off');
- e.preventDefault();
- });
- // mailbox modal message status - confirm selected status
- $(document.body).on('click','#message_status_confirm',function(e) {
- var status = jQuery("select[name=select_status] option:selected").val();
- var newsletter_auto_signup_email_to_newsletter = '';
- if (status == 'newsletter')
- {
- var newsletter_auto_signup_email_to_newsletter = $("input[name=mailbox_newsletter_set]").is(':checked');
- if (newsletter_auto_signup_email_to_newsletter == true)
- newsletter_auto_signup_email_to_newsletter = 1;
- else
- newsletter_auto_signup_email_to_newsletter = 0;
- }
- ajax({action : 'message_status_confirm',mailbox_id : mailbox_id, folder: $("input[name=folder_active]").val(),message_uid : $("input[name=message_uid]").val(),status : status,newsletter_auto_signup_email_to_newsletter:newsletter_auto_signup_email_to_newsletter,email:$("input[name=email]").val()},function(data) {
- $("#status_"+$("input[name=message_uid]").val()).html(data.status_html);
- modal_close();
- });
- });
- });
- if (s1 == 'mailbox')
- {
- $(function() {
- $(document.body).on('click','#contact_save',function(e) {
- email = $("input[name=email]").val();
- company_title = $("input[name=company_title]").val();
- name = $("input[name=name]").val();
- surname = $("input[name=surname]").val();
- mobile = $("input[name=mobile]").val();
- comment = $("textarea[name=comment]").val();
- var groups = [];
- $("input[name='groups[]']:checked").each(function()
- {
- groups.push(parseInt($(this).val()));
- });
- ajax({mailbox_id:mailbox_id,action:'contact_save',email:email,company_title:company_title,name:name,surname:surname,mobile:mobile,comment:comment,groups:groups},function(data) {
- });
- });
- // message attachments modul to move into organizer - select all
- $(document.body).on('click','input[name=attachments_all]',function(e) {
- $is_checked = $(this).is(':checked');
- if ($is_checked == true)
- {
- $("[data-modul=mailbox_message_attachment]").attr('checked','checked');
- }
- if ($is_checked == false)
- {
- $("[data-modul=mailbox_message_attachment]").attr('checked',false);
- }
- });
- // move - copy attachments to organizer - confirmation
- $(document.body).on('click','#move_attachments_now',function(e) {
- var organizer_id = $(".select2_object_organizer").val();
- var attachments = $('input[class=attachment]:checkbox:checked').map(function() {
- return this.value;
- }).get();
- $("#error_attachments").addClass('hidden');
- $("#error_organizer_id").addClass('hidden');
- var error = false;
- if (organizer_id == null)
- {
- $("#error_organizer_id").removeClass('hidden');
- error = true;
- }
- if (attachments.length == 0)
- {
- $("#error_attachments").removeClass('hidden');
- error = true;
- }
- if (error == false)
- {
- var uri = window.location.hash.substr(1);
- uri = uri.split('/');
- uri.unshift('');
- console.log(uri);
- ajax({action:'move_attachments_to_organizer_confirm',mailbox_id:mailbox_id,message_uid:uri[2],organizer_id:organizer_id,attachments:attachments},function(data) {
- });
- }
- });
- });
- // view
- $(document.body).on('mouseover','.tr_message_item',function(e) {
- $(this).find('[data-modul=message_move_to_trash]').removeClass('hidden');
- });
- $(document.body).on('mouseout','.tr_message_item',function(e) {
- $(this).find('[data-modul=message_move_to_trash]').addClass('hidden');
- });
- // contact3
- $(document.body).on('mouseover','.contact_card',function(e) {
- $(this).find('.contact_card_content').removeClass('hidden');
- });
- $(document.body).on('mouseout','.contact_card',function(e) {
- $(this).find('.contact_card_content').addClass('hidden');
- });
- // create -> recipient hover
- $(document.body).on('mouseover','.recipient_list_item',function(e) {
- $(this).find('.recipient_remove_div').removeClass('hidden');
- });
- $(document.body).on('mouseout','.recipient_list_item',function(e) {
- $(this).find('.recipient_remove_div').addClass('hidden');
- });
- // view - switch email account
- $(document.body).on('click','[data-mailbox=switch_email_account]',function(e) {
- ajax({action:'switch_email_account',mailbox_id:mailbox_id});
- });
- /****************************************************************************************************************************************************************************************
- M A I L B O X 2
- ****************************************************************************************************************************************************************************************/
- // subject on change save to session
- $(document.body).on('keyup click','input[name=subject]',function(e) {
- if ($("input[name=subject]").val().length > 0)
- $("input[name=subject]").attr('style','font-size:1.5em; color:black; padding-left:0.3em; border-bottom:2px solid green !important');
- if ($("input[name=subject]").val().length < 3)
- $("input[name=subject]").attr('style','font-size:1.5em; color:black; padding-left:0.3em; border-bottom:2px solid red !important');
- if ($("input[name=subject]").val().length == 0)
- $("input[name=subject]").attr('style','font-size:1.5em; color:black; padding-left:0.3em; border-bottom:2px solid #f7f7f7 !important');
- ajax({action:'mailbox_subject',mailbox_id:mailbox_id,subject:$("input[name=subject]").val()});
- });
- // recipient management
- $(document.body).on('keyup click','.recipient_email',function(e) {
- val = $(this).val();
- nr = $(this).attr('mailbox-recipient-nr');
- if (parseInt(nr) < 10 && valid_email(val))
- $(document.body).find('.recipient_nr_'+(parseInt(nr)+1)).removeClass('hidden');
- $('.recipient_email').each(function() {
- $(this).attr('style','border-bottom:2px solid #f1f1f1 !important');
- nr = $(this).attr('mailbox-recipient-nr');
- if ($(this).val().length > 0)
- {
- if (valid_email($(this).val()))
- {
- $(this).attr('style','border-bottom:2px solid green !important');
- $("#suggesstion-box-"+nr).hide();
- }
- else
- $(this).attr('style','border-bottom:2px solid red !important');
- }
- });
- });
- // AJAX call for autocomplete
- $(document.body).on('keyup click',".recipient_email",function(e){
- recipient_nr = $(this).attr('mailbox-recipient-nr');
- email = $(this).val();
- if (!valid_email(email))
- {
- ajax_stop();
- ajax({action:'mailbox_suggest',mailbox_id:mailbox_id,email:email,recipient_nr:recipient_nr},function(data) {
- $("#suggesstion-box-"+data.recipient_nr).show();
- $("#suggesstion-box-"+data.recipient_nr).html(data.html);
- $("#suggesstion-box-"+data.recipient_nr).fadeOut(5000);
- });
- }
- });
- }
- // autocomplete
- function select_recipient(val,nr) {
- $("input[name=email_recipient_"+nr+"]").val(val);
- $("#suggesstion-box-"+nr).hide();
- if (valid_email($("input[name=email_recipient_"+nr+"]").val()))
- {
- $("input[name=email_recipient_"+nr+"]").attr('style','border-bottom:2px solid green !important');
- if (parseInt(nr) < 10 && valid_email(val))
- {
- $(document.body).find('.recipient_nr_'+(parseInt(nr)+1)).removeClass('hidden');
- ajax({action:'mailbox_suggest_confirm',mailbox_id:mailbox_id,email:val,recipient_nr:nr});
- }
- }
- else
- $("input[name=email_recipient_"+nr+"]").attr('style','border-bottom:2px solid red !important');
- }
- function resizeIframe(obj) {
- obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement