1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 16:13:20 +01:00
invoiceninja/resources/views/proposals/grapesjs.blade.php

84 lines
2.9 KiB
PHP
Raw Normal View History

2018-02-04 22:03:26 +01:00
<script type="text/javascript">
$(function() {
window.grapesjsEditor = grapesjs.init({
container : '#gjs',
2018-03-19 20:16:57 +01:00
components: {!! json_encode($entity ? $entity->html : '') !!},
style: {!! json_encode($entity ? $entity->css : '') !!},
2018-02-04 22:03:26 +01:00
showDevices: false,
plugins: ['gjs-preset-newsletter'],
pluginsOpts: {
'gjs-preset-newsletter': {
'categoryLabel': "{{ trans('texts.standard') }}"
}
},
2018-02-12 16:35:57 +01:00
storageManager: {
type: 'none'
},
assetManager: {
2018-02-12 20:21:49 +01:00
assets: {!! json_encode($documents) !!},
noAssets: "{{ trans('texts.no_assets') }}",
addBtnText: "{{ trans('texts.add_image') }}",
modalTitle: "{{ trans('texts.select_image') }}",
@if (Utils::isSelfHost() || $account->isEnterprise())
upload: {!! json_encode(url('/documents')) !!},
uploadText: "{{ trans('texts.dropzone_default_message') }}",
@else
upload: false,
uploadText: "{{ trans('texts.upgrade_to_upload_images') }}",
@endif
2018-02-12 16:35:57 +01:00
uploadName: 'files',
params: {
2018-02-22 11:06:32 +01:00
'_token': '{{ Session::token() }}',
2018-02-12 16:35:57 +01:00
'grapesjs': true,
}
}
2018-02-04 22:03:26 +01:00
});
var blockManager = grapesjsEditor.BlockManager;
@foreach ($snippets as $snippet)
2018-02-04 22:50:57 +01:00
blockManager.add("h{{ ($loop->index + 1) }}-block", {
2018-02-04 22:03:26 +01:00
label: '{{ $snippet->name }}',
category: '{{ $snippet->proposal_category ? $snippet->proposal_category->name : trans('texts.custom') }}',
2018-03-19 20:16:57 +01:00
content: {!! json_encode($snippet->html) !!},
style: {!! json_encode($snippet->css) !!},
2018-02-04 22:03:26 +01:00
attributes: {
2018-03-19 20:16:57 +01:00
title: {!! json_encode($snippet->private_notes) !!},
class:'fa fa-{{ $snippet->icon ?: 'font' }}'
2018-02-04 22:03:26 +01:00
}
});
@endforeach
@if (count($snippets))
var blockCategories = blockManager.getCategories();
for (var i=0; i<blockCategories.models.length; i++) {
var blockCategory = blockCategories.models[i];
blockCategory.set('open', false);
}
@endif
2018-02-11 09:18:05 +01:00
grapesjsEditor.on('component:update', function(a, b) {
NINJA.formIsChanged = true;
});
2018-02-12 20:21:49 +01:00
grapesjsEditor.on('asset:remove', function(asset) {
sweetConfirm(function() {
$.ajax({
url: "{{ url('/documents') }}/" + asset.attributes.public_id,
type: 'DELETE',
success: function(result) {
console.log('result: %s', result);
}
});
}, "{{ trans('texts.delete_image_help') }}", "{{ trans('texts.delete_image') }}", function() {
var assetManager = grapesjsEditor.AssetManager;
assetManager.add([asset.attributes]);
});
});
2018-02-04 22:03:26 +01:00
});
</script>