Commit c21cb28a9682ee44a9a717f8c06873e4899aeeec

Authored by Karpikau Andrei
1 parent a873f663

small change, locale change

@@ -161,7 +161,9 @@ jQuery(document).ready(function(){ @@ -161,7 +161,9 @@ jQuery(document).ready(function(){
161 161
162 clearAjaxFileUpload($('#work_area .editor-content')); 162 clearAjaxFileUpload($('#work_area .editor-content'));
163 ajaxFileUpload = initAjaxFileUpload($('#work_area .editor-content')); 163 ajaxFileUpload = initAjaxFileUpload($('#work_area .editor-content'));
164 - 164 + };
  165 + if($('.wrapper-edit-content-from-frontend').length > 0){
  166 + initializeFieldForm($('.wrapper-edit-content-from-frontend'));
165 }; 167 };
166 168
167 var getNextStructureIdGLobal = function($content_block){ 169 var getNextStructureIdGLobal = function($content_block){
@@ -336,19 +338,24 @@ jQuery(document).ready(function(){ @@ -336,19 +338,24 @@ jQuery(document).ready(function(){
336 338
337 339
338 340
339 - $('.html-generator').on('ajax:success', '.content-form', function(evt, data, status, xhr){  
340 - $('#work_area').slideUp('slow', function(){  
341 - $('#work_area .editor-content').html(''); 341 + $('.html-generator, .wrapper-edit-content-from-frontend').on('ajax:success', '.content-form', function(evt, data, status, xhr){
  342 + if(data.frontentd == undefined){
  343 + $('#work_area').slideUp('slow', function(){
  344 + $('#work_area .editor-content').html('');
342 345
343 - $('#structure_area').find('.col').each(function(){  
344 - if($(this).data('id') == data.structure_id){  
345 - $(this).find('.col-html').html(data.html);  
346 - }  
347 - }); 346 + $('#structure_area').find('.col').each(function(){
  347 + if($(this).data('id') == data.structure_id){
  348 + $(this).find('.col-html').html(data.html);
  349 + }
  350 + });
348 351
349 - $('#structure_area').find('.col[data-id='+ data.structure_id +'] .col-html').html(data.html);  
350 - $('#structure_area').slideDown('slow');  
351 - }); 352 + $('#structure_area').find('.col[data-id='+ data.structure_id +'] .col-html').html(data.html);
  353 + $('#structure_area').slideDown('slow');
  354 + });
  355 + }else{
  356 + $('[data-id='+ data.structure_id +']', window.parent.document).html(data.html);
  357 + $('iframe[name="content-edit"]', window.parent.document).remove();
  358 + }
352 359
353 }); 360 });
354 361
  1 +jQuery(document).ready(function(){
  2 + $('.frontend-close-layer, .body-frontend-content .cancel-content').click(function(){
  3 + $('iframe[name="content-edit"]', window.parent.document).remove();
  4 + return false;
  5 + });
  6 +
  7 +});
@@ -2,251 +2,6 @@ var csrf_token = $('meta[name=csrf-token]').attr('content'), @@ -2,251 +2,6 @@ var csrf_token = $('meta[name=csrf-token]').attr('content'),
2 csrf_param = $('meta[name=csrf-param]').attr('content'); 2 csrf_param = $('meta[name=csrf-param]').attr('content');
3 3
4 (function() { 4 (function() {
5 - $.FroalaEditor.DEFAULTS.key = 'kKC1KXDF1INBh1KPe2TK==';  
6 -  
7 - $.FroalaEditor.DefineIcon('cms-image', {NAME: 'image'});  
8 - $.FroalaEditor.RegisterCommand('cms-image', {  
9 - title: 'Image',  
10 - focus: false,  
11 - undo: false,  
12 - refreshAfterCallback: false,  
13 - callback: function () {  
14 - var $this = this;  
15 -  
16 - var galleryUrl = $this.$original_element.data('gallery-url');  
17 -  
18 -  
19 -  
20 -  
21 - jQuery.ajax({  
22 - type: 'POST',  
23 - url: galleryUrl,  
24 - success: function (data) {  
25 - var $popover = $this.$original_element.closest('form').find('*[data-cmd="cms-image"]'),  
26 - $data = $(data),  
27 - layer_position = 'left';  
28 -  
29 - if($this.$original_element.froalaEditor('fullscreen.isActive')){  
30 - layer_position = 'bottom';  
31 - $popover = $('.fr-fullscreen').find('*[data-cmd="cms-image"]');  
32 - }  
33 -  
34 -  
35 -  
36 -  
37 - $popover.popover({  
38 - content: $data,  
39 - html: true,  
40 - trigger: 'manual',  
41 - placement: layer_position  
42 - }).on('hidden.bs.popover', function () {  
43 - $popover.popover('destroy');  
44 - }).popover('show');  
45 -  
46 - $('body').on( 'click', function(e) {  
47 - if($popover.next('.popover')){  
48 - if ( !$popover.next('.popover').has(e.target).length ) {$popover.popover('destroy'); }  
49 - }  
50 - });  
51 -  
52 -  
53 - $data.find('.gallery-item').click(function(){  
54 - var img_link = $(this).attr('href');  
55 -  
56 - $this.$original_element.froalaEditor('image.insert', img_link, true, {});  
57 -  
58 -  
59 - return false;  
60 - });  
61 -  
62 -  
63 -  
64 - }  
65 - });  
66 -  
67 -  
68 -  
69 - }  
70 - });  
71 -  
72 - function ViewProgressModal(){  
73 - var html = '<div id="progress-window" class="modal" tabindex="-1" role="dialog" aria-hidden="true" >' +  
74 - '<div class="modal-dialog">' +  
75 - '<div class="modal-content">' +  
76 - '<div class="modal-header"><h4 class="modal-title">Upload in progress ...</h4></div>' +  
77 - '<div class="modal-body" style="height:auto;max-height:none;overflow:none;" > </div>' +  
78 - '</div>' +  
79 - '</div>' +  
80 - '</div> ';  
81 - $(html).modal({show:true, keyboard: false, backdrop: 'static'});  
82 - window.scrollTo(0, 0);  
83 - }  
84 -  
85 - var ajaxFileUpload = undefined;  
86 -  
87 - var initAjaxFileUpload = function(selector){  
88 -  
89 -  
90 - function send_ajax_form($form){  
91 - $('#progress-window').find('.modal-body').append('<div>Upload form data, please wait...</div>');  
92 - var url = $form.attr('action');  
93 -  
94 - if($form.hasClass('simple_submit')){  
95 - $('#progress-window').modal('hide');  
96 - $('#progress-window').remove();  
97 - $form.removeClass('ajax-file-upload-form');  
98 - //$form.unbind('submit', addFileForAjaxUpload);  
99 - $form.unbind('submit', addFileForAjaxUpload);  
100 - $form.submit();  
101 -  
102 - }else{  
103 - $.post(url, $form.serialize(), function(){  
104 - $('#progress-window').modal('hide');  
105 - $('#progress-window').remove();  
106 - });  
107 - }  
108 - }  
109 -  
110 -  
111 -  
112 - addFileForAjaxUpload = function(e){  
113 - var $form = $(this),  
114 - count_files = 0,  
115 - count_upload = 0;  
116 - e.preventDefault();  
117 - e.stopPropagation();  
118 -  
119 - selector.find(".ajax-file-upload-form input:file").each(function(){  
120 - var $this = $(this),  
121 - filesList = $this.data('files');  
122 - if(filesList == undefined){  
123 - filesList = [];  
124 - }  
125 - count_files = count_files + filesList.length;  
126 -  
127 - if(filesList.length > 0) {  
128 - if($('#progress-window').length == 0){  
129 - ViewProgressModal();  
130 - }  
131 -  
132 -  
133 - var fileToSend = [];  
134 - $(filesList).each(function(){  
135 - var item = this,  
136 - class_name = item.input_name.replace (/[\[\]]/g, '-');  
137 -  
138 - var progress_bar = '<div class="'+ class_name +'"><div>' + item.file.name + ':</div><div style="position:relative;"><div style="margin-right:50px;" class="progress"><div class="progress-bar" style="width: 0%;"></div><a href="#" style="color:#FFFFFF;position:absolute;display:none;top:0px;right:0px;" class="cancel-save"><i class="icon-remove"></i></a></div></div></div>';  
139 - $('#progress-window').find('.modal-body').append(progress_bar);  
140 - fileToSend.push(item.file);  
141 - });  
142 -  
143 -  
144 -  
145 -  
146 -  
147 - $this.fileupload('send', {files: fileToSend})  
148 - .complete(function (result, textStatus, jqXHR) {  
149 - count_upload = count_upload + 1;  
150 - if(count_upload == count_files){  
151 - send_ajax_form($form);  
152 - }  
153 -  
154 - });  
155 -  
156 - }  
157 -  
158 - });  
159 - if(count_files == 0){  
160 - send_ajax_form($form);  
161 - }  
162 -  
163 -  
164 -  
165 -  
166 - }  
167 -  
168 - initFileInput = function(fileInputElem){  
169 - var form = $(fileInputElem.parents('form:first'));  
170 - var submitButton = form.find('input[type="submit"]');  
171 -  
172 - var class_name = fileInputElem.attr('name').replace (/[\[\]]/g, '-');  
173 -  
174 - var fileUploadItem = fileInputElem.fileupload({  
175 - fileInput: fileInputElem,  
176 - url: fileInputElem.data('url'),  
177 - type: 'POST',  
178 - autoUpload: false,  
179 - formData: fileInputElem.data('form-data'),  
180 - paramName: 'file', // S3 does not like nested name fields i.e. name="user[avatar_url]"  
181 - dataType: 'XML', // S3 returns XML if success_action_status is set to 201  
182 - replaceFileInput: false,  
183 - add: function(e, data){  
184 - var filesList = [];  
185 - $.each(data.files, function (index, file) {  
186 - filesList.push({input_name: fileInputElem.attr('name'), file: data.files[index]});  
187 - });  
188 - fileInputElem.data('files', filesList);  
189 - },  
190 - progressall: function (e, data) {  
191 - var progress = parseInt(data.loaded / data.total * 100, 10);  
192 -  
193 - $('.' + class_name).find('.progress-bar').css('width', progress + '%');  
194 - },  
195 - start: function (e) {  
196 - submitButton.prop('disabled', true);  
197 -  
198 - $('.' + class_name).find('.progress-bar').css('width', '0%');  
199 - },  
200 - done: function (e, data) {  
201 - submitButton.prop('disabled', false);  
202 -  
203 -  
204 - $('.' + class_name).find('.progress-bar').addClass('progress-bar-success');  
205 -  
206 -  
207 - // extract key and generate URL from response  
208 - var key = $(data.jqXHR.responseXML).find("Key").text();  
209 - var url = 'http://' + fileInputElem.data('host') + '/' + key;  
210 -  
211 - // create hidden field  
212 - var input = $("<input />", {type: 'hidden', name: fileInputElem.attr('name'), value: url})  
213 - form.append(input);  
214 - fileInputElem.val('');  
215 - },  
216 - fail: function (e, data) {  
217 - submitButton.prop('disabled', false);  
218 -  
219 - $('.' + class_name).find('.progress-bar').addClass('progress-bar-danger');  
220 - }  
221 - });  
222 - };  
223 -  
224 - selector.find(".ajax-file-upload-form input:file").each(function () {  
225 - initFileInput($(this));  
226 -  
227 -  
228 - });  
229 -  
230 -  
231 -  
232 - selector.find('.ajax-file-upload-form').submit(addFileForAjaxUpload);  
233 -  
234 -  
235 - return this;  
236 - };  
237 -  
238 -  
239 - var modal = undefined;  
240 -  
241 - $('body').on('ajax:success', '.frontend-content-form', function(evt, data, status, xhr){  
242 - var $cell = $('body').find('.col[data-id='+ data.structure_id +']');  
243 - $cell.html(data.html);  
244 - if(modal != undefined){  
245 - modal.modal('hide');  
246 - }  
247 -  
248 - initCell($cell);  
249 - });  
250 5
251 initCell = function($cell){ 6 initCell = function($cell){
252 var $content = $('<div class="operation"><a class="edit" href="javascript:void(0);"><i class="fa fa-edit"></i></a></div>'); 7 var $content = $('<div class="operation"><a class="edit" href="javascript:void(0);"><i class="fa fa-edit"></i></a></div>');
@@ -254,74 +9,11 @@ var csrf_token = $('meta[name=csrf-token]').attr('content'), @@ -254,74 +9,11 @@ var csrf_token = $('meta[name=csrf-token]').attr('content'),
254 $cell.append($content); 9 $cell.append($content);
255 10
256 $content.find('.edit').click(function(){ 11 $content.find('.edit').click(function(){
257 - alert('1');  
258 - var $iframe = $('<iframe name="content-edit" style="width:500px;height:500px;position: absolute;top: 10%;left: 50%;transform: translateX(-50%);border: 0;" src = "http://www.w3schools.com">This text ensures cross browser compatibility </iframe>');  
259 - $('body').append($iframe);  
260 - alert(edit_layer_url);  
261 - return;  
262 -  
263 var $block = $(this).closest('.col'), 12 var $block = $(this).closest('.col'),
264 - page_data_id = $block.data('page_data_id'),  
265 structure_id = $block.data('id'); 13 structure_id = $block.data('id');
266 14
267 -  
268 -  
269 - //show editor for content  
270 - if(typeof(edit_layer_url) != undefined){  
271 - jQuery.ajax({  
272 - type: 'POST',  
273 - url: edit_layer_url,  
274 - data: {page_data_id: page_data_id, structure_id: structure_id},  
275 - success: function (data) {  
276 -  
277 - var $data = $(data);  
278 -  
279 - $data.find(".fileupload-field").each(function(){  
280 - var $this = $(this),  
281 - $previewBlock = $this.next(),  
282 - options = {'showUpload':false};  
283 -  
284 - if($previewBlock) {  
285 - options['initialPreview'] = $previewBlock.html();  
286 - $previewBlock.remove();  
287 - }  
288 -  
289 -  
290 - $this.fileinput(options);  
291 - });  
292 -  
293 -  
294 - modal = $data.modal({  
295 - show: true,  
296 - backdrop: false  
297 - }).on('shown.bs.modal', function (e) {  
298 -  
299 -  
300 - $('.page_html_content').froalaEditor({  
301 - theme: 'gray',  
302 - height: 400,  
303 - toolbarButtons: ['fontFamily', 'fontSize', '|', 'bold', 'italic', 'underline', 'strikeThrough', '|', 'subscript', 'superscript', '|' ,'color', 'paragraphStyle', 'paragraphFormat', 'align', '|', 'formatOL', 'formatUL', 'outdent', 'indent', '|', 'quote', 'insertHR', '|', 'cms-image', '|', 'insertTable', '|', 'undo', 'redo', 'clearFormatting', '|', 'html', 'fullscreen'],  
304 - toolbarButtonsMD: ['fontFamily', 'fontSize', '|', 'bold', 'italic', 'underline', 'strikeThrough', '|', 'subscript', 'superscript', '|' ,'color', 'paragraphStyle', 'paragraphFormat', 'align', '|', 'formatOL', 'formatUL', 'outdent', 'indent', '|', 'quote', 'insertHR', '|', 'cms-image', '|', 'insertTable', '|', 'undo', 'redo', 'clearFormatting', '|', 'html', 'fullscreen'],  
305 - toolbarButtonsSM: ['fontFamily', 'fontSize', '|', 'bold', 'italic', 'underline', 'strikeThrough', '|', 'subscript', 'superscript', '|' ,'color', 'paragraphStyle', 'paragraphFormat', 'align', '|', 'formatOL', 'formatUL', 'outdent', 'indent', '|', 'quote', 'insertHR', '|', 'cms-image', '|', 'insertTable', '|', 'undo', 'redo', 'clearFormatting', '|', 'html', 'fullscreen'],  
306 - toolbarButtonsXS: ['fontFamily', 'fontSize', '|', 'bold', 'italic', 'underline', 'strikeThrough', '|', 'subscript', 'superscript', '|' ,'color', 'paragraphStyle', 'paragraphFormat', 'align', '|', 'formatOL', 'formatUL', 'outdent', 'indent', '|', 'quote', 'insertHR', '|', 'cms-image', '|', 'insertTable', '|', 'undo', 'redo', 'clearFormatting', '|', 'html', 'fullscreen'],  
307 - imageEditButtons: ['imageAlign', 'imageCaption', 'imageRemove', '|', 'linkOpen', 'linkEdit', 'linkRemove', '-', 'imageDisplay', 'imageStyle', 'imageSize'],  
308 - });  
309 -  
310 - ajaxFileUpload = initAjaxFileUpload($data);  
311 -  
312 -  
313 - }).on('hidden.bs.modal', function (e) {  
314 - modal.remove();  
315 - });  
316 - }  
317 - });  
318 - }  
319 - /*  
320 - var $cell = $(this).closest('.col');  
321 -  
322 -  
323 -  
324 - */ 15 + var $iframe = $('<iframe name="content-edit" style="width:500px;height:500px;position: absolute;top: 10%;left: 50%;transform: translateX(-50%);border: 1px solid black;z-index:10000;background:#FFFFFF;" src = "'+ edit_layer_url + '&structure_id=' + structure_id +'">Sorry your browser does not support inline frames.</iframe>');
  16 + $('body').append($iframe);
325 return false; 17 return false;
326 }); 18 });
327 } 19 }
@@ -331,63 +23,8 @@ var csrf_token = $('meta[name=csrf-token]').attr('content'), @@ -331,63 +23,8 @@ var csrf_token = $('meta[name=csrf-token]').attr('content'),
331 var $cell = $(this); 23 var $cell = $(this);
332 24
333 initCell($cell); 25 initCell($cell);
334 -  
335 -  
336 -  
337 -  
338 - });  
339 -  
340 -  
341 - $(document).on('click', '.add-repeat-row', function(data, status, xhr){  
342 - var $this = $(this),  
343 - url = $this.attr('href');  
344 -  
345 -  
346 - jQuery.ajax({  
347 - type: 'POST',  
348 - url: url,  
349 - success: function (data) {  
350 - var $data = $(data);  
351 -  
352 - $data.find('.page_html_content').froalaEditor({  
353 - theme: 'gray',  
354 - height: 400,  
355 - toolbarButtons: ['fontFamily', 'fontSize', '|', 'bold', 'italic', 'underline', 'strikeThrough', '|', 'subscript', 'superscript', '|' ,'color', 'paragraphStyle', 'paragraphFormat', 'align', '|', 'formatOL', 'formatUL', 'outdent', 'indent', '|', 'quote', 'insertHR', '|', 'cms-image', '|', 'insertTable', '|', 'undo', 'redo', 'clearFormatting', '|', 'html', 'fullscreen'],  
356 - toolbarButtonsMD: ['fontFamily', 'fontSize', '|', 'bold', 'italic', 'underline', 'strikeThrough', '|', 'subscript', 'superscript', '|' ,'color', 'paragraphStyle', 'paragraphFormat', 'align', '|', 'formatOL', 'formatUL', 'outdent', 'indent', '|', 'quote', 'insertHR', '|', 'cms-image', '|', 'insertTable', '|', 'undo', 'redo', 'clearFormatting', '|', 'html', 'fullscreen'],  
357 - toolbarButtonsSM: ['fontFamily', 'fontSize', '|', 'bold', 'italic', 'underline', 'strikeThrough', '|', 'subscript', 'superscript', '|' ,'color', 'paragraphStyle', 'paragraphFormat', 'align', '|', 'formatOL', 'formatUL', 'outdent', 'indent', '|', 'quote', 'insertHR', '|', 'cms-image', '|', 'insertTable', '|', 'undo', 'redo', 'clearFormatting', '|', 'html', 'fullscreen'],  
358 - toolbarButtonsXS: ['fontFamily', 'fontSize', '|', 'bold', 'italic', 'underline', 'strikeThrough', '|', 'subscript', 'superscript', '|' ,'color', 'paragraphStyle', 'paragraphFormat', 'align', '|', 'formatOL', 'formatUL', 'outdent', 'indent', '|', 'quote', 'insertHR', '|', 'cms-image', '|', 'insertTable', '|', 'undo', 'redo', 'clearFormatting', '|', 'html', 'fullscreen'],  
359 - imageEditButtons: ['imageAlign', 'imageCaption', 'imageRemove', '|', 'linkOpen', 'linkEdit', 'linkRemove', '-', 'imageDisplay', 'imageStyle', 'imageSize'],  
360 - });  
361 -  
362 - $('#accordion').append($data);  
363 - $data.find("input:file").each(function () {  
364 - ajaxFileUpload.initFileInput($(this));  
365 - });  
366 -  
367 - }  
368 - });  
369 -  
370 -  
371 - return false;  
372 }); 26 });
373 27
374 - $(document).on('click', '.delete-repeat-row', function(data, status, xhr){  
375 - var $this = $(this),  
376 - url = $this.attr('href');  
377 28
378 29
379 - jQuery.ajax({  
380 - type: 'POST',  
381 - url: url,  
382 - success: function (data) {  
383 - if(data.status == 'ok'){  
384 - $this.closest('.panel').remove();  
385 - }  
386 - }  
387 - });  
388 -  
389 -  
390 - return false;  
391 - });  
392 -  
393 })(); 30 })();
@@ -93,35 +93,7 @@ module Kanjai @@ -93,35 +93,7 @@ module Kanjai
93 end 93 end
94 94
95 def show_editor 95 def show_editor
96 - @page = Page.find(params[:id])  
97 - @page_data = @page.page_data.find_by_lang(params[:lang])  
98 - @structure_id = params[:structure_id]  
99 - @obj = @page_data.page_contents.find_by_structure_id(@structure_id)  
100 - if @obj.nil?  
101 - @obj = PageContent.create({:page => @page, :page_datum => @page_data, :structure_id => @structure_id})  
102 - end  
103 -  
104 - @type_contents = []  
105 - @main_field = []  
106 -  
107 - if page_template = @page_data.page.page_template  
108 - @type_contents += page_template.template_parts.where("part_type in ('content')").collect{|p| [p.name, p.code] }  
109 - page_template.template_parts.where("part_type in ('content')").each do |item|  
110 - item.field_options.each do |el|  
111 - @main_field << el[:name] if el[:main].to_i == 1  
112 - end  
113 - end  
114 - end  
115 -  
116 - @type_contents.sort!{|x,y| x[0] <=> y[0]}  
117 -  
118 - @type_contents.unshift([I18n.t('admin.content_types.plugin'), 'plugin'])  
119 - @type_contents.unshift([I18n.t('admin.content_types.rte_editor'), 'rte_editor'])  
120 -  
121 -  
122 - @type_content = @obj.type_content  
123 -  
124 - @obj.build_markers(@obj.type_content) 96 + prepare_edit_content
125 97
126 render :layout => false 98 render :layout => false
127 end 99 end
@@ -190,7 +162,11 @@ module Kanjai @@ -190,7 +162,11 @@ module Kanjai
190 162
191 @obj.update(permitted_params[:page_content]) 163 @obj.update(permitted_params[:page_content])
192 164
193 - render :json => {:status => 'ok', :structure_id => @structure_id, :html => @obj.get_content} 165 + if params[:frontend_part]
  166 + render :json => {:status => 'ok', :structure_id => @structure_id, frontentd: 1, :html => @obj.get_content_frontend}
  167 + else
  168 + render :json => {:status => 'ok', :structure_id => @structure_id, :html => @obj.get_content}
  169 + end
194 end 170 end
195 171
196 def gallery 172 def gallery
@@ -292,20 +268,9 @@ module Kanjai @@ -292,20 +268,9 @@ module Kanjai
292 end 268 end
293 269
294 def show_frontend_editor 270 def show_frontend_editor
295 - @page = Page.find(params[:id])  
296 - @page_data = @page.page_data.find(params[:page_data_id])  
297 - @structure_id = params[:structure_id]  
298 - @obj = @page_data.page_contents.find_by_structure_id(@structure_id)  
299 - if @obj.nil?  
300 - @obj = PageContent.new  
301 - end  
302 -  
303 - @type_content = @obj.type_content  
304 -  
305 - @obj.build_markers(@obj.type_content)  
306 -  
307 -  
308 - render :layout => false 271 + prepare_edit_content
  272 + @frontend = true
  273 + render layout: 'kanjai/frontend_content'
309 end 274 end
310 275
311 def update_frontend_editor 276 def update_frontend_editor
@@ -352,6 +317,38 @@ module Kanjai @@ -352,6 +317,38 @@ module Kanjai
352 end 317 end
353 end 318 end
354 319
  320 + def prepare_edit_content
  321 + @page = Page.find(params[:id])
  322 + @page_data = @page.page_data.find_by_lang(params[:lang])
  323 + @structure_id = params[:structure_id]
  324 + @obj = @page_data.page_contents.find_by_structure_id(@structure_id)
  325 + if @obj.nil?
  326 + @obj = PageContent.create({:page => @page, :page_datum => @page_data, :structure_id => @structure_id})
  327 + end
  328 +
  329 + @type_contents = []
  330 + @main_field = []
  331 +
  332 + if page_template = @page_data.page.page_template
  333 + @type_contents += page_template.template_parts.where("part_type in ('content')").collect{|p| [p.name, p.code] }
  334 + page_template.template_parts.where("part_type in ('content')").each do |item|
  335 + item.field_options.each do |el|
  336 + @main_field << el[:name] if el[:main].to_i == 1
  337 + end
  338 + end
  339 + end
  340 +
  341 + @type_contents.sort!{|x,y| x[0] <=> y[0]}
  342 +
  343 + @type_contents.unshift([I18n.t('admin.content_types.plugin'), 'plugin'])
  344 + @type_contents.unshift([I18n.t('admin.content_types.rte_editor'), 'rte_editor'])
  345 +
  346 +
  347 + @type_content = @obj.type_content
  348 +
  349 + @obj.build_markers(@obj.type_content)
  350 + end
  351 +
355 352
356 end 353 end
357 end 354 end
@@ -137,7 +137,7 @@ module Kanjai @@ -137,7 +137,7 @@ module Kanjai
137 when '###VARIABLE_FOR_EDIT_CONTENT###' 137 when '###VARIABLE_FOR_EDIT_CONTENT###'
138 content = '' 138 content = ''
139 if current_admin_user 139 if current_admin_user
140 - content = show_editor_admin_page_url(@page_data.page, lang: @page_data.lang) 140 + content = show_frontend_editor_admin_page_url(@page_data.page, lang: @page_data.lang)
141 end 141 end
142 layer.gsub!(marker, content) 142 layer.gsub!(marker, content)
143 when '###CSRF_PARAM###' 143 when '###CSRF_PARAM###'
@@ -70,7 +70,6 @@ module Kanjai @@ -70,7 +70,6 @@ module Kanjai
70 "data-id=#{row['attributes']['id']}", 70 "data-id=#{row['attributes']['id']}",
71 "data-page_data_id=#{page_data.id}" 71 "data-page_data_id=#{page_data.id}"
72 ] 72 ]
73 -  
74 html += ApplicationController.render(file: 'kanjai/pages/templates/block', assigns: {content: cells.html_safe, data_attributes: data_attributes.join(' ')}, layout: false).html_safe 73 html += ApplicationController.render(file: 'kanjai/pages/templates/block', assigns: {content: cells.html_safe, data_attributes: data_attributes.join(' ')}, layout: false).html_safe
75 74
76 #html += ActionController::Base.helpers.content_tag(:div, '', html_attributes) do 75 #html += ActionController::Base.helpers.content_tag(:div, '', html_attributes) do
@@ -24,8 +24,8 @@ @@ -24,8 +24,8 @@
24 <% end %> 24 <% end %>
25 </div> 25 </div>
26 <div class="btn-group"> 26 <div class="btn-group">
27 - <%= link_to 'Choose Image', get_files_admin_images_url, class: 'btn btn-primary content-choose-image' %>  
28 - <%= link_to 'Remove Image', get_files_admin_images_url, class: "btn btn-danger content-remove-image #{form2.object.text_value.present? ? '' : 'not-visible'}" %> 27 + <%= link_to t('actions.choose_file'), get_files_admin_images_url, class: 'btn btn-primary content-choose-image' %>
  28 + <%= link_to t('actions.remove_file'), get_files_admin_images_url, class: "btn btn-danger content-remove-image #{form2.object.text_value.present? ? '' : 'not-visible'}" %>
29 </div> 29 </div>
30 <% end %> 30 <% end %>
31 <% if form2.object.get_marker_type(@type_content) == 'form' %> 31 <% if form2.object.get_marker_type(@type_content) == 'form' %>
@@ -121,8 +121,8 @@ @@ -121,8 +121,8 @@
121 <% end %> 121 <% end %>
122 </div> 122 </div>
123 <div class="btn-group"> 123 <div class="btn-group">
124 - <%= link_to 'Choose Image', get_files_admin_images_url, class: 'btn btn-primary content-choose-image' %>  
125 - <%= link_to 'Remove Image', get_files_admin_images_url, class: "btn btn-danger content-remove-image #{form2.object.text_value.present? ? '' : 'not-visible'}" %> 124 + <%= link_to t('actions.choose_file'), get_files_admin_images_url, class: 'btn btn-primary content-choose-image' %>
  125 + <%= link_to t('actions.remove_file'), get_files_admin_images_url, class: "btn btn-danger content-remove-image #{form2.object.text_value.present? ? '' : 'not-visible'}" %>
126 </div> 126 </div>
127 <% end %> 127 <% end %>
128 128
1 -<%= form_for(@obj, :url => update_editor_admin_page_url(@page, structure_id: @structure_id, lang: params[:lang]), :remote => true, :html => {:class => "content-form ajax-file-upload-form simple_submit", :method => 'POST'}) do |form| %> 1 +<%= form_for(@obj, :url => update_editor_admin_page_url(@page, structure_id: @structure_id, lang: params[:lang], frontend_part: @frontend ? 1 : 0), :remote => true, :html => {:class => "content-form ajax-file-upload-form simple_submit", :method => 'POST'}) do |form| %>
2 <div class="clearfix content-type-wrapper"> 2 <div class="clearfix content-type-wrapper">
3 <div class="form-group row"> 3 <div class="form-group row">
4 <%= form.label :type_content, t('activerecord.attributes.page_content.type_content'), :class => "col-md-2 col-form-label" %> 4 <%= form.label :type_content, t('activerecord.attributes.page_content.type_content'), :class => "col-md-2 col-form-label" %>
1 -<div class="modal fade" tabindex="-1" role="dialog">  
2 - <div class="modal-dialog">  
3 - <div class="modal-content">  
4 - <%= form_for(@obj, :url => update_frontend_editor_admin_page_url(@page_data.page, structure_id: @structure_id, page_data_id: @page_data.id), :remote => true, :html => {:class => "frontend-content-form ajax-file-upload-form simple_submit", :method => 'POST'}) do |form| %>  
5 - <div class="modal-header">  
6 - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>  
7 - <h4 class="modal-title"><%= t('edit_frontend_page_title') %></h4>  
8 - </div>  
9 - <div class="modal-body"> 1 +<div class="wrapper-edit-content-from-frontend">
  2 + <%= render template: 'kanjai/admin/pages/show_editor' %>
  3 +</div>
10 4
11 - <% partial, locals = Kanjai::PageContent.edit_template(@obj.type_content) %>  
12 -  
13 - <%= render :partial => partial, locals: locals %>  
14 -  
15 - </div>  
16 - <div class="modal-footer">  
17 - <button type="button" class="btn btn-default" data-dismiss="modal"><%= t('actions.close') %></button>  
18 - <%= submit_tag t('actions.create'), :class => 'btn btn-primary' %>  
19 - </div>  
20 - <% end %>  
21 - </div><!-- /.modal-content -->  
22 - </div><!-- /.modal-dialog -->  
23 -</div><!-- /.modal -->  
@@ -3,5 +3,5 @@ @@ -3,5 +3,5 @@
3 </div> 3 </div>
4 4
5 <script type="text/javascript"> 5 <script type="text/javascript">
6 - var edit_layer_url = '<%= show_editor_admin_page_url(@page_data.page, lang: @page_data.lang) %>'; 6 + var edit_layer_url = '<%= show_frontend_editor_admin_page_url(@page_data.page, lang: @page_data.lang) %>';
7 </script> 7 </script>
1 -<div class="col"> 1 +<div class="col" <%= @data_attributes %>>
2 <%= @content %> 2 <%= @content %>
3 </div> 3 </div>
  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 +
  4 +<head>
  5 + <meta charset="utf-8">
  6 + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  7 +
  8 + <%= csrf_meta_tags %>
  9 +
  10 + <title><%= t('meta_title') %></title><!-- =============== VENDOR STYLES ===============-->
  11 + <!-- FONT AWESOME-->
  12 + <%= stylesheet_link_tag "kanjai/general" %>
  13 +</head>
  14 +
  15 +<body class="layout-h body-frontend-content">
  16 + <div style="margin:30px;">
  17 + <div class="text-right">
  18 + <a href='#' class="frontend-close-layer btn-primary btn">Close</a>
  19 + </div>
  20 + <div class="wrapper">
  21 + <!-- top navbar-->
  22 + <section class="section-container">
  23 + <%= yield %>
  24 +
  25 + </section><!-- Page footer-->
  26 +
  27 + </div><!-- =============== VENDOR SCRIPTS ===============-->
  28 + </div>
  29 + <!-- MODERNIZR-->
  30 + <%= javascript_include_tag "kanjai/general" %>
  31 +</body>
  32 +
  33 +</html>
@@ -117,6 +117,8 @@ en: @@ -117,6 +117,8 @@ en:
117 copy: "Copy" 117 copy: "Copy"
118 add_more_images: "Add More Images" 118 add_more_images: "Add More Images"
119 back_to_choose_image: "Back to choose image" 119 back_to_choose_image: "Back to choose image"
  120 + choose_file: "Choose File"
  121 + remove_file: "Remove File"
120 122
121 admin: 123 admin:
122 page_structure: 124 page_structure:
@@ -39,7 +39,7 @@ Kanjai::Engine.routes.draw do @@ -39,7 +39,7 @@ Kanjai::Engine.routes.draw do
39 post :update_editor, on: :member 39 post :update_editor, on: :member
40 post :duplicate_block, on: :member 40 post :duplicate_block, on: :member
41 41
42 - post :show_frontend_editor, on: :member 42 + get :show_frontend_editor, on: :member
43 post :update_frontend_editor, on: :member 43 post :update_frontend_editor, on: :member
44 44
45 get :activate, on: :member 45 get :activate, on: :member
1 module Kanjai 1 module Kanjai
2 - VERSION = "0.0.166" 2 + VERSION = "0.0.167"
3 end 3 end