Skip to content

Commit

Permalink
CSP compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Sep 30, 2023
1 parent 1e88014 commit aff6e4a
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 45 deletions.
51 changes: 42 additions & 9 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,26 @@ $(document).ready(function(){
e.preventDefault();
});

//applyVoidLinks();
$('ul.customer-contacts a.contact-main').click(function(e) {
copyToClipboard($(this).text());
e.preventDefault();
});

// Dirty JS hack because there was no way found to expand outer container when sidebar grows.
if ($('#conv-layout-customer').length && $(window).outerWidth() >= 1100 && $('.conv-sidebar-block').length > 2) {
adjustCustomerSidebarHeight();
setTimeout(adjustCustomerSidebarHeight, 2000);
}
}
});

/*function applyVoidLinks()
{
$('a.void-link').click(function(e) {
e.preventDefault();
});
}*/

function initMuteMailbox()
{
$('.mailbox-mute-trigger, .mailbox-mute-trigger span').click(function(e) {
Expand Down Expand Up @@ -611,11 +624,13 @@ function fsFixEditorCodeSaving($el)
function permissionsInit()
{
$(document).ready(function(){
$('.sel-all').click(function(event) {
$('.sel-all').click(function(e) {
$("#permissions-fields input").attr('checked', 'checked');
e.preventDefault();
});
$('.sel-none').click(function(event) {
$('.sel-none').click(function(e) {
$("#permissions-fields input").removeAttr('checked');
e.preventDefault();
});
});
}
Expand Down Expand Up @@ -818,7 +833,7 @@ function logsInit()
function multiInputInit()
{
$(document).ready(function() {
$('.multi-add').click(function() {
$('.multi-add').click(function(e) {
var clone = $(this).parents('.multi-container:first').children('.multi-item:first').clone(true, true);
var index = parseInt($(this).parents('.multi-container:first').children('.block-help:last').attr('data-max-i'));
if (isNaN(index)) {
Expand All @@ -838,13 +853,16 @@ function multiInputInit()
clone.insertAfter($(this).parents('.multi-container:first').children('.multi-item:last'));

$(this).parents('.multi-container:first').children('.block-help:last').attr('data-max-i', index);

e.preventDefault();
});
$('.multi-remove').click(function() {
$('.multi-remove').click(function(e) {
if ($(this).parents('.multi-container:first').children('.multi-item').length > 1) {
$(this).parents('.multi-item:first').remove();
} else {
$(this).parents('.multi-item:first').children(':input').val('');
}
e.preventDefault();
});
} );
}
Expand Down Expand Up @@ -1744,7 +1762,7 @@ function editorSendFile(file, attach, is_conv, editor_id, container)

// Show loader
if (attach) {
var attachment_html = '<li class="atachment-upload-'+attachment_dummy_id+'"><img src="'+Vars.public_url+'/img/loader-tiny.gif" width="16" height="16"/> <a href="javascript:void(0);" class="break-words disabled" target="_blank">'+file.name+'<span class="ellipsis">…</span> </a> <span class="text-help">('+formatBytes(file.size)+')</span> <i class="glyphicon glyphicon-remove" data-attachment-id="'+attachment_dummy_id+'"></i></li>';
var attachment_html = '<li class="atachment-upload-'+attachment_dummy_id+'"><img src="'+Vars.public_url+'/img/loader-tiny.gif" width="16" height="16"/> <a href="#" class="break-words disabled" target="_blank">'+file.name+'<span class="ellipsis">…</span> </a> <span class="text-help">('+formatBytes(file.size)+')</span> <i class="glyphicon glyphicon-remove" data-attachment-id="'+attachment_dummy_id+'"></i></li>';
attachments_container.children('ul:first').append(attachment_html);

// Delete attachment
Expand Down Expand Up @@ -1856,9 +1874,10 @@ function initNewConversation(is_phone)
if (typeof(is_phone) != "undefined") {
switchToNewPhoneConversation();
}
$('#toggle-email').click(function() {
$('#toggle-email').click(function(e) {
$('#field-to_email').show();
$(this).hide();
e.preventDefault();
});
$('#email-conv-switch').click(function() {
switchToNewEmailConversation();
Expand Down Expand Up @@ -1973,10 +1992,11 @@ function initReplyForm(load_attachments, init_customer_selector, is_new_conv)
}

// Show CC
$('#toggle-cc').click(function() {
$('#toggle-cc').click(function(e) {
$('.field-cc').removeClass('hidden');
$(this).parent().remove();
initRecipientSelector();
e.preventDefault();
});

// After send
Expand Down Expand Up @@ -2065,7 +2085,12 @@ function initReplyForm(load_attachments, init_customer_selector, is_new_conv)
});

e.preventDefault();
})
});

$('#conv-subject .switch-to-note').click(function(e) {
switchToNote();
e.preventDefault();
});
});
}

Expand Down Expand Up @@ -5011,6 +5036,14 @@ function inApp(topic, token)
if (!getCookie('in_app')) {
setCookie('in_app', '1');
}
$('#navbar-back').click(function(e) {
goBack();
e.preventDefault();
});
$('a.in-app-switcher').click(function(e) {
switchHelpdeskUrl();
e.preventDefault();
});
});
}

Expand Down
4 changes: 2 additions & 2 deletions resources/views/conversations/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
</div>

<div class="col-sm-9 col-sm-offset-2 toggle-field phone-conv-fields" id="toggle-email">
<a href="javascript:void(0);">{{ __('Add Email') }}</a>
<a href="#">{{ __('Add Email') }}</a>
</div>
</div>

Expand Down Expand Up @@ -202,7 +202,7 @@
</div>

<div class="col-sm-9 col-sm-offset-2 email-conv-fields toggle-field @if ($conversation->cc && $conversation->bcc) hidden @endif">
<a href="javascript:void(0);" class="help-link" id="toggle-cc">Cc/Bcc</a>
<a href="#" class="help-link" id="toggle-cc">Cc/Bcc</a>
</div>

<div class="form-group{{ $errors->has('subject') ? ' has-error' : '' }}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<button type="button" class="btn btn-primary btn-send-menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><small class="glyphicon glyphicon-chevron-down"></small></button>
<ul class="dropdown-menu dropdown-menu-right dropdown-after-send">
@action('conversation.prepend_send_dropdown', $conversation, $mailbox, $new_converstion ?? false)
<li @if ($after_send == App\MailboxUser::AFTER_SEND_STAY) class="active" @endif><a href="javascript:void(0)" data-after-send="{{ App\MailboxUser::AFTER_SEND_STAY }}">{{ __('Send and stay on page') }}</a></li>
<li @if ($after_send == App\MailboxUser::AFTER_SEND_STAY) class="active" @endif><a href="#" data-after-send="{{ App\MailboxUser::AFTER_SEND_STAY }}">{{ __('Send and stay on page') }}</a></li>
<li @if ($after_send == App\MailboxUser::AFTER_SEND_NEXT) class="active" @endif><a href="#" data-after-send="{{ App\MailboxUser::AFTER_SEND_NEXT }}">{{ __('Send and next active') }}</a></li>
<li @if ($after_send == App\MailboxUser::AFTER_SEND_FOLDER) class="active" @endif><a href="#" data-after-send="{{ App\MailboxUser::AFTER_SEND_FOLDER }}">{{ __('Send and back to folder') }}</a></li>
@if (empty($new_converstion))
Expand Down
5 changes: 2 additions & 3 deletions resources/views/conversations/partials/thread.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
[{{ __('Draft') }}]
</div>
<div class="btn-group btn-group-xs draft-actions">
<a class="btn btn-default edit-draft-trigger" href="javascript:void(0);">{{ __('Edit') }}</a>
<a class="btn btn-default discard-draft-trigger" href="javascript:void(0)">{{ __('Discard') }}</a>
<a class="btn btn-default edit-draft-trigger" href="#">{{ __('Edit') }}</a>
<a class="btn btn-default discard-draft-trigger" href="#">{{ __('Discard') }}</a>
</div>
</div>
<div class="thread-info">
Expand Down Expand Up @@ -299,7 +299,6 @@
@if ($thread->isNote() && !$thread->first && Auth::user()->can('delete', $thread))
<li><a href="#" class="thread-delete-trigger" role="button" data-loading-text="{{ __("Delete") }}">{{ __("Delete") }}</a></li>
@endif
{{--<li><a href="javascript:alert('todo: implement hiding threads');void(0);" title="" class="thread-hide-trigger">{{ __("Hide") }} (todo)</a></li>--}}
<li><a href="{{ route('conversations.create', ['mailbox_id' => $mailbox->id]) }}?from_thread_id={{ $thread->id }}" title="{{ __("Start a conversation from this thread") }}" class="new-conv" role="button">{{ __("New Conversation") }}</a></li>
@if ($thread->isCustomerMessage())
<li><a href="{{ route('conversations.clone_conversation', ['mailbox_id' => $mailbox->id, 'from_thread_id' => $thread->id]) }}" title="{{ __("Clone a conversation from this thread") }}" class="new-conv" role="button">{{ __("Clone Conversation") }}</a></li>
Expand Down
1 change: 0 additions & 1 deletion resources/views/conversations/search.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
@endif
@endforeach
@endif
{{--<li class="menu-padded"><a href="javascript: alert('todo: implement recent search');void(0);" class="help-link">{{ __('more') }}…</a></li>--}}
<li class="no-link"><span class="text-help">{{ __('Filters') }}</span></li>
@foreach ($filters_list as $filter)
<li class="menu-link menu-padded">
Expand Down
6 changes: 3 additions & 3 deletions resources/views/conversations/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@
<div class="form-group cc-toggler @if (empty($to_customers) && !$cc && !$bcc) cc-shifted @endif @if ($cc && $bcc) hidden @endif">
<label class="control-label"></label>
<div class="conv-reply-field">
<a href="javascript:void(0);" class="help-link" id="toggle-cc">Cc/Bcc</a>
<a href="#" class="help-link" id="toggle-cc">Cc/Bcc</a>
</div>
</div>

@if (!empty($threads[0]) && $threads[0]->type == App\Thread::TYPE_NOTE && $threads[0]->created_by_user_id != Auth::user()->id && $threads[0]->created_by_user)
<div class="alert alert-warning alert-switch-to-note">
<i class="glyphicon glyphicon-exclamation-sign"></i>
{!! __('This reply will go to the customer. :%switch_start%Switch to a note:switch_end if you are replying to :user_name.', ['%switch_start%' => '<a href="javascript:switchToNote();void(0);">', 'switch_end' => '</a>', 'user_name' => htmlspecialchars($threads[0]->created_by_user->getFullName()) ]) !!}
{!! __('This reply will go to the customer. :%switch_start%Switch to a note:switch_end if you are replying to :user_name.', ['%switch_start%' => '<a href="#" class="switch-to-note">', 'switch_end' => '</a>', 'user_name' => htmlspecialchars($threads[0]->created_by_user->getFullName()) ]) !!}
</div>
@endif

Expand Down Expand Up @@ -270,7 +270,7 @@
<div class="conv-customer-block conv-sidebar-block">
@include('customers/profile_snippet', ['customer' => $customer, 'main_email' => $conversation->customer_email, 'conversation' => $conversation])
<div class="dropdown customer-trigger" data-toggle="tooltip" title="{{ __("Settings") }}">
<a href="javascript:void(0)" class="dropdown-toggle glyphicon glyphicon-cog" data-toggle="dropdown" ></a>
<a href="#" class="dropdown-toggle glyphicon glyphicon-cog" data-toggle="dropdown" ></a>
<ul class="dropdown-menu dropdown-menu-right" role="menu">
<li role="presentation"><a href="{{ route('customers.update', ['id' => $customer->id]) }}" tabindex="-1" role="menuitem">{{ __("Edit Profile") }}</a></li>
@if (!$conversation->isChat())
Expand Down
20 changes: 10 additions & 10 deletions resources/views/customers/partials/edit_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
<div class="multi-item {{ $errors->has('emails.'.$i) ? ' has-error' : '' }}">
<div>
<input type="email" class="form-control input-sized-lg" name="emails[]" value="{{ $email }}" maxlength="191">
<a href="javascript:void(0)" class="multi-remove" tabindex="-1"><i class="glyphicon glyphicon-remove"></i></a>
<a href="#" class="multi-remove" tabindex="-1"><i class="glyphicon glyphicon-remove"></i></a>
</div>

@include('partials/field_error', ['field'=>'emails.'.$i])
</div>
@endforeach
<p class="block-help"><a href="javascript:void(0)" class="multi-add " tabindex="-1">{{ __('Add an email address') }}</a></p>
<p class="block-help"><a href="#" class="multi-add " tabindex="-1">{{ __('Add an email address') }}</a></p>
</div>

{{-- @include('partials/field_error', ['field'=>'emails.*']) --}}
Expand All @@ -67,12 +67,12 @@
</select>
<input type="tel" class="form-control " name="phones[{{ $i }}][value]" value="{{ $phone['value'] }}">
</div>
<a href="javascript:void(0)" class="multi-remove" tabindex="-1"><i class="glyphicon glyphicon-remove"></i></a>
<a href="#" class="multi-remove" tabindex="-1"><i class="glyphicon glyphicon-remove"></i></a>
</div>
</div>
@endif
@endforeach
<p class="block-help" data-max-i="{{ $i }}"><a href="javascript:void(0)" class="multi-add" tabindex="-1">{{ __('Add a phone number') }}</a></p>
<p class="block-help" data-max-i="{{ $i }}"><a href="#" class="multi-add" tabindex="-1">{{ __('Add a phone number') }}</a></p>
</div>

@include('partials/field_error', ['field'=>'phones'])
Expand Down Expand Up @@ -108,11 +108,11 @@
<div class="multi-item">
<div>
<input type="url" class="form-control input-sized-lg" name="websites[]" value="{{ $website }}" maxlength="100">
<a href="javascript:void(0)" class="multi-remove" tabindex="-1"><i class="glyphicon glyphicon-remove"></i></a>
<a href="#" class="multi-remove" tabindex="-1"><i class="glyphicon glyphicon-remove"></i></a>
</div>
</div>
@endforeach
<p class="block-help"><a href="javascript:void(0)" class="multi-add" tabindex="-1">{{ __('Add a website') }}</a></p>
<p class="block-help"><a href="#" class="multi-add" tabindex="-1">{{ __('Add a website') }}</a></p>
</div>

@include('partials/field_error', ['field'=>'websites'])
Expand All @@ -138,12 +138,12 @@
<span class="input-group-btn" style="width:0px;"></span>
<input type="text" class="form-control" name="social_profiles[{{ $i }}][value]" value="{{ $social_profile['value'] }}">
</div>
<a href="javascript:void(0)" class="multi-remove" tabindex="-1"><i class="glyphicon glyphicon-remove"></i></a>
<a href="#" class="multi-remove" tabindex="-1"><i class="glyphicon glyphicon-remove"></i></a>
</div>
</div>
@endif
@endforeach
<p class="block-help" data-max-i="{{ $i }}"><a href="javascript:void(0)" class="multi-add" tabindex="-1">{{ __('Add a social profile') }}</a></p>
<p class="block-help" data-max-i="{{ $i }}"><a href="#" class="multi-add" tabindex="-1">{{ __('Add a social profile') }}</a></p>
</div>

@include('partials/field_error', ['field'=>'social_profiles'])
Expand Down Expand Up @@ -187,14 +187,14 @@
</select>

<div class="block-help small margin-bottom-0">
<a href="javascript:$('#address-collapse').toggleClass('hidden');void(0);">{{ __('Address') }} <span class="caret"></span></a>
<a href="#address-collapse" data-toggle="collapse">{{ __('Address') }} <span class="caret"></span></a>
</div>

@include('partials/field_error', ['field'=>'country'])
</div>
</div>

<div id="address-collapse" @if (empty(old('state', $customer->state)) && empty(old('city', $customer->city)) && empty(old('address', $customer->address)) && empty(old('zip', $customer->zip)))class="hidden" @endif>
<div id="address-collapse" @if (empty(old('state', $customer->state)) && empty(old('city', $customer->city)) && empty(old('address', $customer->address)) && empty(old('zip', $customer->zip)))@else class="collapse in" @endif>

<div class="form-group{{ $errors->has('state') ? ' has-error' : '' }}">
<label for="state" class="col-sm-2 control-label">{{ __('State') }}</label>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/customers/profile_menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@endphp
@if ($profile_menu)
<div class="dropdown customer-profile-menu">
<a href="javascript:void(0)" class="dropdown-toggle glyphicon glyphicon-cog link-grey" data-toggle="dropdown"></a>
<a href="#" class="dropdown-toggle glyphicon glyphicon-cog link-grey" data-toggle="dropdown"></a>
<ul class="dropdown-menu dropdown-menu-right">
{!! $profile_menu !!}
</ul>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/customers/profile_snippet.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
@foreach ($customer->emails as $email)
@if ($email->email == $main_email)
<li class="customer-email">
<a href="javascript:copyToClipboard('{{ $email->email }}')" class="contact-main" data-toggle="tooltip" title="{{ __('Copy') }}">{{ $email->email }}</a>
<a href="#" class="contact-main" data-toggle="tooltip" title="{{ __('Copy') }}">{{ $email->email }}</a>
</li>
@endif
@endforeach
@endif
@foreach ($customer->emails as $email)
@if (empty($main_email) || $email->email != $main_email)
<li class="customer-email">
<a href="javascript:copyToClipboard('{{ $email->email }}')" class="contact-main" data-toggle="tooltip" title="{{ __('Copy') }}">{{ $email->email }}</a>
<a href="#" class="contact-main" data-toggle="tooltip" title="{{ __('Copy') }}">{{ $email->email }}</a>
</li>
@endif
@endforeach
Expand Down
Loading

0 comments on commit aff6e4a

Please sign in to comment.