|
...
|
...
|
@@ -2,251 +2,6 @@ var csrf_token = $('meta[name=csrf-token]').attr('content'), |
|
2
|
2
|
csrf_param = $('meta[name=csrf-param]').attr('content');
|
|
3
|
3
|
|
|
4
|
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
|
6
|
initCell = function($cell){
|
|
252
|
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
|
9
|
$cell.append($content);
|
|
255
|
10
|
|
|
256
|
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
|
12
|
var $block = $(this).closest('.col'),
|
|
264
|
|
- page_data_id = $block.data('page_data_id'),
|
|
265
|
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
|
17
|
return false;
|
|
326
|
18
|
});
|
|
327
|
19
|
}
|
|
...
|
...
|
@@ -331,63 +23,8 @@ var csrf_token = $('meta[name=csrf-token]').attr('content'), |
|
331
|
23
|
var $cell = $(this);
|
|
332
|
24
|
|
|
333
|
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
|
})(); |
|
|
\ No newline at end of file |
...
|
...
|
|