fronty-gem 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/app/controllers/concerns/dynamic_content.rb +160 -0
- data/app/controllers/designers_controller.rb +257 -0
- data/app/controllers/pages_controller.rb +23 -0
- data/app/views/designers/editor.html.erb +245 -0
- data/app/views/pages/404.html.erb +2 -0
- data/app/views/pages/welcome.html.erb +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/initializers/assets.rb +2 -0
- data/config/routes.rb +20 -0
- data/fronty-gem.gemspec +37 -0
- data/lib/config/routes.rb +3 -0
- data/lib/fronty-gem.rb +5 -0
- data/lib/fronty-gem/version.rb +3 -0
- data/lib/tasks/fronty.rake +14 -0
- data/vendor/assets/demo/album/album.css +39 -0
- data/vendor/assets/demo/album/index.html +231 -0
- data/vendor/assets/demo/blog/blog.css +130 -0
- data/vendor/assets/demo/blog/index.html +230 -0
- data/vendor/assets/demo/carousel/carousel.css +91 -0
- data/vendor/assets/demo/carousel/index.html +186 -0
- data/vendor/assets/demo/narrow-jumbotron/index.html +82 -0
- data/vendor/assets/demo/narrow-jumbotron/narrow-jumbotron.css +80 -0
- data/vendor/assets/demo/offcanvas/index.html +158 -0
- data/vendor/assets/demo/offcanvas/offcanvas.css +79 -0
- data/vendor/assets/demo/offcanvas/offcanvas.js +7 -0
- data/vendor/assets/demo/pricing/index.html +141 -0
- data/vendor/assets/demo/pricing/pricing.css +25 -0
- data/vendor/assets/demo/product/index.html +177 -0
- data/vendor/assets/demo/product/product.css +79 -0
- data/vendor/assets/fonts/line-awesome.eot +0 -0
- data/vendor/assets/fonts/line-awesome.svg +2628 -0
- data/vendor/assets/fonts/line-awesome.ttf +0 -0
- data/vendor/assets/fonts/line-awesome.woff +0 -0
- data/vendor/assets/fonts/line-awesome.woff2 +0 -0
- data/vendor/assets/images/icons/alert.svg +66 -0
- data/vendor/assets/images/icons/arrow-down.svg +60 -0
- data/vendor/assets/images/icons/arrow-right.svg +60 -0
- data/vendor/assets/images/icons/badge.svg +81 -0
- data/vendor/assets/images/icons/breadcrumbs.svg +77 -0
- data/vendor/assets/images/icons/button.svg +78 -0
- data/vendor/assets/images/icons/button_group.svg +81 -0
- data/vendor/assets/images/icons/button_toolbar.svg +87 -0
- data/vendor/assets/images/icons/cart.svg +62 -0
- data/vendor/assets/images/icons/categories.svg +62 -0
- data/vendor/assets/images/icons/chart.svg +1 -0
- data/vendor/assets/images/icons/checkbox.svg +66 -0
- data/vendor/assets/images/icons/checkout.svg +62 -0
- data/vendor/assets/images/icons/chevron-down.svg +67 -0
- data/vendor/assets/images/icons/chevron-right.svg +67 -0
- data/vendor/assets/images/icons/components/cart.svg +16 -0
- data/vendor/assets/images/icons/components/checkbox.svg +1 -0
- data/vendor/assets/images/icons/components/contact-form.svg +13 -0
- data/vendor/assets/images/icons/components/map.svg +12 -0
- data/vendor/assets/images/icons/container.svg +66 -0
- data/vendor/assets/images/icons/facebook.svg +1 -0
- data/vendor/assets/images/icons/file.svg +1 -0
- data/vendor/assets/images/icons/filters.svg +62 -0
- data/vendor/assets/images/icons/folder.svg +1 -0
- data/vendor/assets/images/icons/form.svg +66 -0
- data/vendor/assets/images/icons/grid_row.svg +66 -0
- data/vendor/assets/images/icons/heading.svg +66 -0
- data/vendor/assets/images/icons/hr.svg +66 -0
- data/vendor/assets/images/icons/image.svg +62 -0
- data/vendor/assets/images/icons/instagram.svg +62 -0
- data/vendor/assets/images/icons/jumbotron.svg +66 -0
- data/vendor/assets/images/icons/label.svg +73 -0
- data/vendor/assets/images/icons/link.svg +1 -0
- data/vendor/assets/images/icons/list_group.svg +66 -0
- data/vendor/assets/images/icons/map.svg +62 -0
- data/vendor/assets/images/icons/maps.png +0 -0
- data/vendor/assets/images/icons/minus_round.svg +1 -0
- data/vendor/assets/images/icons/navbar.svg +66 -0
- data/vendor/assets/images/icons/pagination.svg +68 -0
- data/vendor/assets/images/icons/panel.svg +66 -0
- data/vendor/assets/images/icons/paragraph.svg +66 -0
- data/vendor/assets/images/icons/paypal.svg +1 -0
- data/vendor/assets/images/icons/play-button.svg +42 -0
- data/vendor/assets/images/icons/plus_round.svg +1 -0
- data/vendor/assets/images/icons/product.png +0 -0
- data/vendor/assets/images/icons/product.svg +62 -0
- data/vendor/assets/images/icons/product_gallery.svg +68 -0
- data/vendor/assets/images/icons/products.svg +62 -0
- data/vendor/assets/images/icons/progressbar.svg +67 -0
- data/vendor/assets/images/icons/radio.svg +66 -0
- data/vendor/assets/images/icons/search.svg +69 -0
- data/vendor/assets/images/icons/select_input.svg +67 -0
- data/vendor/assets/images/icons/slider.svg +62 -0
- data/vendor/assets/images/icons/table.svg +66 -0
- data/vendor/assets/images/icons/text_area.svg +66 -0
- data/vendor/assets/images/icons/text_input.svg +66 -0
- data/vendor/assets/images/icons/twitter.svg +55 -0
- data/vendor/assets/images/icons/user.svg +62 -0
- data/vendor/assets/images/icons/video.svg +45 -0
- data/vendor/assets/images/icons/well.svg +82 -0
- data/vendor/assets/images/svg/icon-a.svg +235 -0
- data/vendor/assets/images/svg/icon-b.svg +224 -0
- data/vendor/assets/images/svg/icon-c.svg +224 -0
- data/vendor/assets/images/svg/icon-d.svg +224 -0
- data/vendor/assets/images/svg/logo.svg +41 -0
- data/vendor/assets/images/thumbnails/XX__.png +0 -0
- data/vendor/assets/images/thumbnails/comparison.png +0 -0
- data/vendor/assets/images/thumbnails/details-with-title-complate.png +0 -0
- data/vendor/assets/images/thumbnails/details.png +0 -0
- data/vendor/assets/images/thumbnails/footer-with-links.png +0 -0
- data/vendor/assets/images/thumbnails/footer.png +0 -0
- data/vendor/assets/images/thumbnails/header.png +0 -0
- data/vendor/assets/images/thumbnails/jumbotron-with-title.png +0 -0
- data/vendor/assets/images/thumbnails/jumbotron.png +0 -0
- data/vendor/assets/images/thumbnails/linkbar.png +0 -0
- data/vendor/assets/images/thumbnails/liticle.png +0 -0
- data/vendor/assets/images/thumbnails/logobar.png +0 -0
- data/vendor/assets/images/thumbnails/page-title.png +0 -0
- data/vendor/assets/images/thumbnails/quiz-complate.png +0 -0
- data/vendor/assets/images/thumbnails/quiz-with-hero-complate.png +0 -0
- data/vendor/assets/images/thumbnails/result-complate.png +0 -0
- data/vendor/assets/images/thumbnails/review-section.png +0 -0
- data/vendor/assets/images/thumbnails/review-v2-complate.png +0 -0
- data/vendor/assets/images/thumbnails/review-v3-complate.png +0 -0
- data/vendor/assets/images/thumbnails/review_section_v4_complate.png +0 -0
- data/vendor/assets/images/thumbnails/split-hero-complate.png +0 -0
- data/vendor/assets/images/thumbnails/subtitle-with-button-complate.png +0 -0
- data/vendor/assets/images/thumbnails/subtitle-with-link.png +0 -0
- data/vendor/assets/images/thumbnails/unknown-complate.png +0 -0
- data/vendor/assets/images/thumbnails/unknown1-complate.png +0 -0
- data/vendor/assets/images/thumbnails/video-section-complate.png +0 -0
- data/vendor/assets/javascript/fronty-designer-init.js +491 -0
- data/vendor/assets/javascript/fronty-designer.js +16518 -0
- data/vendor/assets/stylesheets/fronty-designer.css +11255 -0
- metadata +235 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 500 125" style="enable-background:new 0 0 500 125;" xml:space="preserve">
|
4
|
+
<style type="text/css">
|
5
|
+
.st0{fill:url(#SVGID_1_);}
|
6
|
+
.st1{fill:url(#SVGID_2_);}
|
7
|
+
.st2{fill:url(#SVGID_3_);}
|
8
|
+
.st3{fill:url(#SVGID_4_);}
|
9
|
+
.st4{fill:url(#SVGID_5_);}
|
10
|
+
</style>
|
11
|
+
<g id="Layer_1">
|
12
|
+
|
13
|
+
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="229.9" y1="50.45" x2="486.1" y2="50.45" gradientTransform="matrix(1 0 0 -1 0 126)">
|
14
|
+
<stop offset="0" style="stop-color:#666666"/>
|
15
|
+
<stop offset="1" style="stop-color:#8D8E92"/>
|
16
|
+
</linearGradient>
|
17
|
+
<path class="st0" d="M266.2,32.8v7.4H239v20h25v7.3h-25.1v26.9h-9V32.8H266.2z M273.1,94.5v-46h6.5l1.5,9.2 c1.1-2.9,2.9-5.3,5.5-7.1c2.5-1.8,5.5-2.7,8.8-2.7c1.7,0,3.1,0.1,4.2,0.4c1.1,0.3,2.1,0.6,3,1l-1.7,7.5c-0.8-0.4-1.6-0.7-2.6-1 c-0.9-0.3-2.1-0.4-3.4-0.4c-1.9,0-3.6,0.3-5.2,1s-3,1.6-4.2,2.9c-1.2,1.3-2.2,2.9-2.8,4.8c-0.7,1.9-1,4.1-1,6.6v23.8H273.1z M349.5,71c0,3.9-0.6,7.3-1.8,10.3c-1.2,3-2.8,5.6-4.8,7.7c-2.1,2.1-4.5,3.7-7.2,4.8s-5.7,1.6-8.9,1.6c-3.2,0-6.2-0.5-8.9-1.5 s-5.1-2.5-7.1-4.5s-3.6-4.4-4.7-7.3s-1.7-6.2-1.7-10c0-3.9,0.6-7.3,1.8-10.3c1.2-3,2.8-5.5,4.8-7.6s4.5-3.6,7.2-4.7 c2.7-1.1,5.7-1.6,8.9-1.6c3.2,0,6.2,0.5,8.9,1.5c2.7,1,5.1,2.4,7.1,4.4s3.6,4.4,4.7,7.3C348.9,63.9,349.5,67.2,349.5,71z M340.5,71.5c0-3.1-0.4-5.7-1.2-7.8c-0.8-2.2-1.8-3.9-3.1-5.3c-1.3-1.4-2.7-2.4-4.4-3c-1.6-0.6-3.3-0.9-5-0.9s-3.4,0.3-5,0.8 s-3.1,1.4-4.3,2.7c-1.2,1.3-2.2,3.1-3,5.2c-0.8,2.2-1.1,4.9-1.1,8.3c0,3.1,0.4,5.7,1.2,7.9c0.8,2.2,1.8,4,3.1,5.3s2.7,2.4,4.4,3 c1.6,0.7,3.3,1,5,1s3.4-0.3,5-0.8c1.6-0.6,3.1-1.5,4.3-2.8c1.2-1.3,2.2-3.1,3-5.3C340.1,77.6,340.5,74.8,340.5,71.5z M368.6,94.5 H360v-46h6.8l1.3,6.4c2.3-2.3,4.7-4,7.2-5.2s5.4-1.8,8.7-1.8c4.7,0,8.4,1.3,11.1,4c2.7,2.6,4,6.3,4,11v31.7h-8.6V64 c0-2.8-0.7-5-2.2-6.7s-3.7-2.5-6.7-2.5c-4.6,0-8.8,2.1-12.8,6.2v33.5H368.6z M436,54.9h-13.5v26.7c0,2.3,0.6,3.8,1.7,4.6 c1.1,0.8,2.6,1.2,4.5,1.2c1.3,0,2.7-0.1,4.3-0.4c1.6-0.3,2.9-0.6,4.1-1l1.4,6.6c-1.3,0.5-3,1-5,1.4s-4.1,0.6-6.4,0.6 c-4.6,0-7.9-1-10-3s-3.1-4.9-3.1-8.7v-28h-6.9v-6.5h6.9V33.8h8.5v14.7H436V54.9z M442.6,48.5h9.2l9.8,26.3l3.3,11h0.2l3.3-11 l8.9-26.3h8.8l-17.7,49.9c-2,5.5-4.4,9.9-7.4,13s-6.5,5.4-10.6,6.9l-3.7-6.9c3.1-1.2,5.8-2.9,8.2-5.1c2.4-2.2,4.2-5.3,5.5-9.2 l0.9-2.6L442.6,48.5z"/>
|
18
|
+
</g>
|
19
|
+
<g id="Layer_2">
|
20
|
+
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="55.3656" y1="16.2" x2="55.3656" y2="111.2">
|
21
|
+
<stop offset="0" style="stop-color:#FF2D55;stop-opacity:0.8"/>
|
22
|
+
<stop offset="1" style="stop-color:#FF2676;stop-opacity:0.8"/>
|
23
|
+
</linearGradient>
|
24
|
+
<polygon class="st1" points="58.7,16.2 96.4,16.2 52,63.7 96.4,111.2 58.7,111.2 14.3,63.7 "/>
|
25
|
+
<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="160.1625" y1="16.2" x2="160.1625" y2="111.2">
|
26
|
+
<stop offset="0" style="stop-color:#007AFF;stop-opacity:0.8"/>
|
27
|
+
<stop offset="1" style="stop-color:#00B9FF;stop-opacity:0.8"/>
|
28
|
+
</linearGradient>
|
29
|
+
<polygon class="st2" points="156.8,111.2 119.1,111.2 163.5,63.7 119.1,16.2 156.8,16.2 201.2,63.7 "/>
|
30
|
+
<linearGradient id="SVGID_4_" gradientUnits="userSpaceOnUse" x1="88.1656" y1="16.2" x2="88.1656" y2="111.2">
|
31
|
+
<stop offset="0" style="stop-color:#000000;stop-opacity:0.7"/>
|
32
|
+
<stop offset="1" style="stop-color:#000000;stop-opacity:0.7"/>
|
33
|
+
</linearGradient>
|
34
|
+
<polygon class="st3" points="124.4,16.2 85.2,63.7 124.4,111.2 91.1,111.2 51.9,63.7 91.1,16.2 "/>
|
35
|
+
<linearGradient id="SVGID_5_" gradientUnits="userSpaceOnUse" x1="127.3625" y1="16.2" x2="127.3625" y2="111.2">
|
36
|
+
<stop offset="0" style="stop-color:#FFCC00;stop-opacity:0.7"/>
|
37
|
+
<stop offset="1" style="stop-color:#FF8D00;stop-opacity:0.7"/>
|
38
|
+
</linearGradient>
|
39
|
+
<polygon class="st4" points="91.1,111.2 130.3,63.7 91.1,16.2 124.4,16.2 163.6,63.7 124.4,111.2 "/>
|
40
|
+
</g>
|
41
|
+
</svg>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,491 @@
|
|
1
|
+
const token = $('meta[name="csrf-token"]').attr('content');
|
2
|
+
|
3
|
+
|
4
|
+
function getCurrentPage() {
|
5
|
+
return window.location.hash.split('#')[1].split('/')[1];
|
6
|
+
}
|
7
|
+
|
8
|
+
|
9
|
+
function showAlert(message, type) {
|
10
|
+
let flashAlert = $('.flash-message');
|
11
|
+
|
12
|
+
if (type === 'error') {
|
13
|
+
type = 'danger'
|
14
|
+
}
|
15
|
+
|
16
|
+
flashAlert.find('.alert-text').text(message);
|
17
|
+
flashAlert.addClass(`bg-${type}`);
|
18
|
+
flashAlert.removeClass('d-none');
|
19
|
+
|
20
|
+
setTimeout(function () {
|
21
|
+
flashAlert.addClass('d-none');
|
22
|
+
}, 3000);
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
function loadPages() {
|
27
|
+
$('.alert-close').on('click', function() {
|
28
|
+
$('.flash-message').addClass('d-none');
|
29
|
+
});
|
30
|
+
// let x = $('select[name=startTemplateUrl]');
|
31
|
+
|
32
|
+
fetch('/get_pages', {
|
33
|
+
method: 'GET',
|
34
|
+
headers: {
|
35
|
+
'X-Requested-With': 'XMLHttpRequest',
|
36
|
+
'X-CSRF-Token': token
|
37
|
+
},
|
38
|
+
credentials: 'same-origin'
|
39
|
+
}).then(function (response) {
|
40
|
+
return response.json();
|
41
|
+
}).then(function (routes) {
|
42
|
+
let newRoutes = [];
|
43
|
+
for (let i = 0; i < routes.length; i++) {
|
44
|
+
newRoutes.push({
|
45
|
+
name: routes[i]['id'],
|
46
|
+
title: routes[i]['title'],
|
47
|
+
url: routes[i]['route'],
|
48
|
+
thumbnail: routes[i]['thumbnail'],
|
49
|
+
redirect_to: routes[i]['redirect_to']
|
50
|
+
});
|
51
|
+
}
|
52
|
+
|
53
|
+
Fronty.Gui.init();
|
54
|
+
Fronty.FileManager.init();
|
55
|
+
|
56
|
+
Fronty.FileManager.addPages = function (pages) {
|
57
|
+
for (page in pages) {
|
58
|
+
this.pages[pages[page]['name']] = {
|
59
|
+
title: pages[page]['title'],
|
60
|
+
url: pages[page]['url'],
|
61
|
+
thumbnail: pages[page]['thumbnail'],
|
62
|
+
redirect_to: pages[page]['redirect']
|
63
|
+
};
|
64
|
+
|
65
|
+
this.tree.append(
|
66
|
+
tmpl("fronty-filemanager-page-custom", {
|
67
|
+
name: pages[page]['name'],
|
68
|
+
title: pages[page]['title'],
|
69
|
+
url: pages[page]['url'],
|
70
|
+
thumbnail: pages[page]['thumbnail'],
|
71
|
+
redirect_to: pages[page]['redirect_to']
|
72
|
+
})
|
73
|
+
);
|
74
|
+
|
75
|
+
|
76
|
+
$('select[name="startTemplateUrl"]').append($(`<option value="${pages[page]['url']}">${pages[page]['title']}</option>`));
|
77
|
+
}
|
78
|
+
};
|
79
|
+
|
80
|
+
Fronty.FileManager.addPages(newRoutes);
|
81
|
+
|
82
|
+
let currentPageRoute = getCurrentPage();
|
83
|
+
|
84
|
+
if (!currentPageRoute) {
|
85
|
+
currentPageRoute = newRoutes[0].name;
|
86
|
+
}
|
87
|
+
|
88
|
+
Fronty.FileManager.loadPage(currentPageRoute);
|
89
|
+
|
90
|
+
return newRoutes;
|
91
|
+
}).then(function (newRoutes) {
|
92
|
+
$('a[rel="popover"]').popover({
|
93
|
+
html: true,
|
94
|
+
content: function () {
|
95
|
+
if ($(this).data('thumbnail'))
|
96
|
+
return '<img src="' + $(this).data('thumbnail') + '" alt="" width="90" class="rounded">';
|
97
|
+
if ($(this).data('redirect'))
|
98
|
+
return $(this).data('redirect');
|
99
|
+
},
|
100
|
+
template: '<div class="popover shadow-sm" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body p-0"></div></div>'
|
101
|
+
});
|
102
|
+
});
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
(function () {
|
107
|
+
// Add image editor icon on select menu
|
108
|
+
$('#drag-btn').after($(' <a id="edit-image-btn" href="" title="Edit image"><i class="la la-pencil"></i></a>'));
|
109
|
+
|
110
|
+
|
111
|
+
$("#edit-image-btn").on("mousedown", function (event) {
|
112
|
+
jQuery("#select-box").hide();
|
113
|
+
|
114
|
+
$('#image-edit-modal').modal();
|
115
|
+
|
116
|
+
var node = Fronty.Builder.selectedEl.get(0);
|
117
|
+
|
118
|
+
var imageEditor = new tui.ImageEditor('#tui-image-editor', {
|
119
|
+
includeUI: {
|
120
|
+
loadImage: {
|
121
|
+
path: node.src,
|
122
|
+
name: 'SampleImage'
|
123
|
+
},
|
124
|
+
theme: blackTheme,
|
125
|
+
menuBarPosition: 'bottom'
|
126
|
+
},
|
127
|
+
usageStatistics: false,
|
128
|
+
cssMaxWidth: 800,
|
129
|
+
cssMaxHeight: 800
|
130
|
+
});
|
131
|
+
|
132
|
+
$(document).off('click', '.apply-image-changes');
|
133
|
+
|
134
|
+
$('.tui-image-editor-download-btn').hide().after('<button class="apply-image-changes">Apply</button>');
|
135
|
+
|
136
|
+
$(document).on('click', '.apply-image-changes', function (event) {
|
137
|
+
node.src = imageEditor.toDataURL();
|
138
|
+
|
139
|
+
$('#image-edit-modal').modal('hide');
|
140
|
+
|
141
|
+
event.preventDefault();
|
142
|
+
return false;
|
143
|
+
});
|
144
|
+
|
145
|
+
event.preventDefault();
|
146
|
+
return false;
|
147
|
+
});
|
148
|
+
|
149
|
+
$('#top-panel').append($(`
|
150
|
+
<div class="btn-group mr-3" role="group">
|
151
|
+
<button class="btn btn-light" title="Update from Repo" id="git-pull">
|
152
|
+
<i class="la la-cloud-download"></i>
|
153
|
+
</button>
|
154
|
+
<button class="btn btn-light" title="Commit to Repo" id="git-push">
|
155
|
+
<i class="la la-cloud-upload"></i>
|
156
|
+
</button>
|
157
|
+
</div>
|
158
|
+
`));
|
159
|
+
|
160
|
+
let filesList = $('.tree ol');
|
161
|
+
|
162
|
+
$('#git-pull').on('click', function () {
|
163
|
+
fetch('/designer/git_pull', {
|
164
|
+
method: 'POST',
|
165
|
+
headers: {
|
166
|
+
'X-Requested-With': 'XMLHttpRequest',
|
167
|
+
'X-CSRF-Token': token,
|
168
|
+
'Accept': 'application/json',
|
169
|
+
'Content-Type': 'application/json',
|
170
|
+
},
|
171
|
+
credentials: 'same-origin'
|
172
|
+
}).then(function (response) {
|
173
|
+
return response.json()
|
174
|
+
}).then(function (data) {
|
175
|
+
console.log(data);
|
176
|
+
})
|
177
|
+
});
|
178
|
+
|
179
|
+
$('#git-push').on('click', function () {
|
180
|
+
fetch('/designer/git_push', {
|
181
|
+
method: 'POST',
|
182
|
+
headers: {
|
183
|
+
'X-Requested-With': 'XMLHttpRequest',
|
184
|
+
'X-CSRF-Token': token,
|
185
|
+
'Accept': 'application/json',
|
186
|
+
'Content-Type': 'application/json',
|
187
|
+
},
|
188
|
+
credentials: 'same-origin'
|
189
|
+
}).then(function (response) {
|
190
|
+
return response.json()
|
191
|
+
}).then(function (data) {
|
192
|
+
console.log(data);
|
193
|
+
})
|
194
|
+
});
|
195
|
+
|
196
|
+
Fronty.Builder.init();
|
197
|
+
loadPages();
|
198
|
+
|
199
|
+
|
200
|
+
$('input[name="is_home"]').change(function () {
|
201
|
+
let routeInput = $('input[name="route"]');
|
202
|
+
if (this.checked) {
|
203
|
+
routeInput.val('/');
|
204
|
+
routeInput.prop('disabled', true);
|
205
|
+
} else {
|
206
|
+
routeInput.val('');
|
207
|
+
routeInput.prop('disabled', false);
|
208
|
+
}
|
209
|
+
});
|
210
|
+
|
211
|
+
// New Page modal radio
|
212
|
+
$('input[name="new_page_type"]').on('change', function () {
|
213
|
+
var value = $('input[name="new_page_type"]:checked').val();
|
214
|
+
$('.page-type').addClass('d-none');
|
215
|
+
$('.page-type.' + value).removeClass('d-none');
|
216
|
+
});
|
217
|
+
|
218
|
+
$('#save-btn').on('click', function (e) {
|
219
|
+
e.preventDefault();
|
220
|
+
|
221
|
+
let route = Fronty.FileManager.getCurrentUrl();
|
222
|
+
let html = Fronty.Builder.getHtml();
|
223
|
+
|
224
|
+
let formData = new FormData();
|
225
|
+
formData.append('authenticity_token', token);
|
226
|
+
formData.append('route', route);
|
227
|
+
formData.append('html', html);
|
228
|
+
|
229
|
+
$.ajax({
|
230
|
+
type: "POST",
|
231
|
+
url: '/designer/save',
|
232
|
+
data: formData,
|
233
|
+
contentType: false,
|
234
|
+
processData: false,
|
235
|
+
success: function (data, response) {
|
236
|
+
showAlert('Data successfully saved!', 'success');
|
237
|
+
loadPages();
|
238
|
+
},
|
239
|
+
error: function () {
|
240
|
+
showAlert('Document not saved!', 'error');
|
241
|
+
}
|
242
|
+
});
|
243
|
+
});
|
244
|
+
|
245
|
+
filesList.on('click', 'a[rel="popover"]', function (e) {
|
246
|
+
e.preventDefault();
|
247
|
+
if (!$(this).data('redirect')) {
|
248
|
+
window.location.hash = '#/' + $(this).parent().attr('for');
|
249
|
+
// $('a[rel="popover"]').popover('dispose');
|
250
|
+
$(this).parent('label').trigger('click');
|
251
|
+
// $(this).parent().next('input').prop('checked', true)
|
252
|
+
console.log('asd', this)
|
253
|
+
// loadPages();
|
254
|
+
}
|
255
|
+
});
|
256
|
+
|
257
|
+
filesList.on('click', '.page-remove', function (e) {
|
258
|
+
e.preventDefault();
|
259
|
+
let self = this;
|
260
|
+
|
261
|
+
fetch('/designer/remove', {
|
262
|
+
method: 'POST',
|
263
|
+
body: JSON.stringify({
|
264
|
+
route: $(self).parent().data('url')
|
265
|
+
}),
|
266
|
+
headers: {
|
267
|
+
'X-Requested-With': 'XMLHttpRequest',
|
268
|
+
'X-CSRF-Token': token,
|
269
|
+
'Accept': 'application/json',
|
270
|
+
'Content-Type': 'application/json',
|
271
|
+
},
|
272
|
+
credentials: 'same-origin'
|
273
|
+
}).then(function (response) {
|
274
|
+
return response.json();
|
275
|
+
}).then(function (response) {
|
276
|
+
loadPages();
|
277
|
+
})
|
278
|
+
});
|
279
|
+
|
280
|
+
filesList.on('click', '.page-edit', function (e) {
|
281
|
+
e.preventDefault();
|
282
|
+
|
283
|
+
let editModal = $('#editModal'),
|
284
|
+
redirectField = $('form[name="editForm"] input[name="redirect"]'),
|
285
|
+
routeField = $('form[name="editForm"] input[name="route"]'),
|
286
|
+
titleField = $('form[name="editForm"] input[name="title"]'),
|
287
|
+
nameField = $('form[name="editForm"] input[name="name"]'),
|
288
|
+
idField = $('form[name="editForm"] input[name="id"]');
|
289
|
+
|
290
|
+
editModal.modal('show');
|
291
|
+
let route = $(this).parent().data('url');
|
292
|
+
|
293
|
+
fetch('/designer/get_page_by_route', {
|
294
|
+
method: 'POST',
|
295
|
+
body: JSON.stringify({
|
296
|
+
route: route,
|
297
|
+
}),
|
298
|
+
headers: {
|
299
|
+
'X-Requested-With': 'XMLHttpRequest',
|
300
|
+
'X-CSRF-Token': token,
|
301
|
+
'Accept': 'application/json',
|
302
|
+
'Content-Type': 'application/json',
|
303
|
+
},
|
304
|
+
credentials: 'same-origin'
|
305
|
+
}).then(function (response) {
|
306
|
+
return response.json();
|
307
|
+
}).then(function (data) {
|
308
|
+
let redirectTo = data.redirect_to,
|
309
|
+
route = data.route,
|
310
|
+
title = data.title,
|
311
|
+
name = data.name,
|
312
|
+
id = data.id;
|
313
|
+
|
314
|
+
redirectField.val(redirectTo);
|
315
|
+
routeField.val(route);
|
316
|
+
titleField.val(title);
|
317
|
+
nameField.val(name);
|
318
|
+
idField.val(id);
|
319
|
+
});
|
320
|
+
});
|
321
|
+
|
322
|
+
$('#new-page-modal').on('shown.bs.modal', function (e) {
|
323
|
+
let $form = $(this).find('form');
|
324
|
+
|
325
|
+
$form.off().submit(function (e) {
|
326
|
+
e.preventDefault();
|
327
|
+
let formData = new FormData();
|
328
|
+
|
329
|
+
let attachment = $form.find('input[name=image]'),
|
330
|
+
template = $form.find('select[name=startTemplateUrl]'),
|
331
|
+
titleField = $form.find('input[name=title]'),
|
332
|
+
routeField = $form.find('input[name=route]'),
|
333
|
+
redirectField = $form.find('input[name=redirectUrl]');
|
334
|
+
|
335
|
+
formData.append('image', attachment[0].files[0]);
|
336
|
+
formData.append('template', template.val());
|
337
|
+
formData.append('title', titleField.val());
|
338
|
+
formData.append('route', routeField.val());
|
339
|
+
|
340
|
+
let preLoading;
|
341
|
+
if (!template.val()) {
|
342
|
+
console.log(template);
|
343
|
+
let $progressBar = $(`<div class="progress"><div class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>`);
|
344
|
+
|
345
|
+
$('#new-page-modal .modal-body .form-group').hide();
|
346
|
+
$('#new-page-modal .modal-footer').empty();
|
347
|
+
$('#new-page-modal .modal-body').append($progressBar);
|
348
|
+
|
349
|
+
let s = 0;
|
350
|
+
preLoading = setInterval(function () {
|
351
|
+
if (s === 10) {
|
352
|
+
clearInterval(preLoading);
|
353
|
+
}
|
354
|
+
$('.progress .progress-bar').text(s + '%');
|
355
|
+
$('.progress .progress-bar').attr('style', `width: ${s}%;`);
|
356
|
+
s++;
|
357
|
+
}, 1000);
|
358
|
+
}
|
359
|
+
|
360
|
+
$.ajax({
|
361
|
+
type: "POST",
|
362
|
+
url: '/designer/create',
|
363
|
+
data: formData,
|
364
|
+
contentType: false,
|
365
|
+
processData: false,
|
366
|
+
success: function (data) {
|
367
|
+
if (data.status === 'success') {
|
368
|
+
|
369
|
+
window.location.hash = '#/' + data.id;
|
370
|
+
$('#new-page-modal').modal('hide');
|
371
|
+
loadPages()
|
372
|
+
return
|
373
|
+
}
|
374
|
+
|
375
|
+
clearInterval(preLoading);
|
376
|
+
|
377
|
+
let thumbnailUrl = data.thumbnail;
|
378
|
+
var job_id = data.job_id;
|
379
|
+
var start = 10;
|
380
|
+
var maxPercent = 11;
|
381
|
+
var timer = setInterval(function () {
|
382
|
+
fetch('/designer/get_status/' + job_id, {
|
383
|
+
method: 'GET',
|
384
|
+
headers: {
|
385
|
+
'Accept': 'application/json',
|
386
|
+
'Content-Type': 'application/json',
|
387
|
+
'X-Requested-With': 'XMLHttpRequest',
|
388
|
+
'X-CSRF-Token': token
|
389
|
+
},
|
390
|
+
credentials: 'same-origin'
|
391
|
+
}).then(function (response) {
|
392
|
+
return response.json();
|
393
|
+
}).then(function (response) {
|
394
|
+
var maxPercentFromServer = response.data.meta.percent;
|
395
|
+
if (maxPercent === maxPercentFromServer && start < maxPercent) {
|
396
|
+
start += 1
|
397
|
+
} else if (maxPercent < maxPercentFromServer) {
|
398
|
+
start = maxPercent;
|
399
|
+
maxPercent = maxPercentFromServer
|
400
|
+
}
|
401
|
+
$('.progress .progress-bar').text(start + '%');
|
402
|
+
$('.progress .progress-bar').attr('style', `width: ${start}%;`);
|
403
|
+
if (['finished', 'failed'].includes(response.data.status)) {
|
404
|
+
clearInterval(timer);
|
405
|
+
var formData = new FormData();
|
406
|
+
|
407
|
+
let route = routeField.val();
|
408
|
+
if (route[0] !== '/') {
|
409
|
+
route = '/' + route;
|
410
|
+
}
|
411
|
+
|
412
|
+
formData.append('title', titleField.val());
|
413
|
+
formData.append('route', route);
|
414
|
+
formData.append('uid', response.data.meta.uid);
|
415
|
+
formData.append('redirect', redirectField.val());
|
416
|
+
formData.append('thumbnail', thumbnailUrl);
|
417
|
+
fetch('/designer/create_new_page', {
|
418
|
+
method: 'POST',
|
419
|
+
headers: {
|
420
|
+
'X-Requested-With': 'XMLHttpRequest',
|
421
|
+
'X-CSRF-Token': token
|
422
|
+
},
|
423
|
+
credentials: 'same-origin',
|
424
|
+
body: formData
|
425
|
+
}).then(function (response) {
|
426
|
+
return response.json();
|
427
|
+
}).then(function (data) {
|
428
|
+
window.location.hash = '#/' + data.id;
|
429
|
+
$('#new-page-modal').modal('hide');
|
430
|
+
loadPages()
|
431
|
+
})
|
432
|
+
}
|
433
|
+
})
|
434
|
+
}, 1000);
|
435
|
+
},
|
436
|
+
beforeSend: function (xhr) {
|
437
|
+
xhr.setRequestHeader('X-CSRF-Token', token)
|
438
|
+
}
|
439
|
+
});
|
440
|
+
})
|
441
|
+
});
|
442
|
+
|
443
|
+
|
444
|
+
$('form[name="editForm"] button').on('click', function (e) {
|
445
|
+
e.preventDefault();
|
446
|
+
|
447
|
+
let redirect = $('form[name="editForm"] input[name="redirect"]').val(),
|
448
|
+
route = $('form[name="editForm"] input[name="route"]').val(),
|
449
|
+
title = $('form[name="editForm"] input[name="title"]').val(),
|
450
|
+
id = $('form[name="editForm"] input[name="id"]').val();
|
451
|
+
|
452
|
+
console.log(redirect);
|
453
|
+
|
454
|
+
if (route[0] !== '/') {
|
455
|
+
route = '/' + route;
|
456
|
+
}
|
457
|
+
|
458
|
+
fetch('/designer/update', {
|
459
|
+
method: 'POST',
|
460
|
+
body: JSON.stringify({
|
461
|
+
redirect: redirect,
|
462
|
+
route: route,
|
463
|
+
title: title,
|
464
|
+
id: id
|
465
|
+
}),
|
466
|
+
headers: {
|
467
|
+
'X-Requested-With': 'XMLHttpRequest',
|
468
|
+
'X-CSRF-Token': token,
|
469
|
+
'Accept': 'application/json',
|
470
|
+
'Content-Type': 'application/json',
|
471
|
+
},
|
472
|
+
credentials: 'same-origin'
|
473
|
+
}).then(function (response) {
|
474
|
+
return response.json();
|
475
|
+
}).then(function (response) {
|
476
|
+
$('#editModal').modal('hide');
|
477
|
+
showAlert('Data successfully updated!', 'success');
|
478
|
+
loadPages();
|
479
|
+
}).catch(function () {
|
480
|
+
showAlert('Document not updated!', 'error');
|
481
|
+
})
|
482
|
+
});
|
483
|
+
|
484
|
+
// Fronty.Builder.frameHtml.on("click", function(event) {
|
485
|
+
// jQuery("#select-box").find('#edit-image-btn').hide();
|
486
|
+
//
|
487
|
+
// if(Fronty.Builder.selectedEl.get(0).nodeName == "IMG") {
|
488
|
+
// jQuery("#select-box").find('#edit-image-btn').show();
|
489
|
+
// }
|
490
|
+
// });
|
491
|
+
})();
|