Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15027 | Rev 15140 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15139 stevensc 1
<?php
1 www 2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
7
 
8
 
9
$routeDatatable = $this->url('microlearning/content/capsules');
10
 
11
$allowAdd       = $acl->isAllowed($roleName, 'microlearning/content/capsules/add') ? 1 : 0;
12
$allowEdit      = $acl->isAllowed($roleName, 'microlearning/content/capsules/edit') ? 1 : 0;
13
$allowDelete    = $acl->isAllowed($roleName, 'microlearning/content/capsules/delete') ? 1 : 0;
14
$allowUsers     = $acl->isAllowed($roleName, 'microlearning/content/capsules/users') ? 1 : 0;
15
 
16
 
17
 
15139 stevensc 18
$this->headLink()->setStyle($this->basePath('plugins/nelberth-editor/style.css'));
1 www 19
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
20
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
21
 
22
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
23
 
24
 
25
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/css/fileinput.min.css'));
26
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.css'));
27
 
28
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/piexif.js'));
29
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/sortable.js'));
30
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/fileinput.js'));
31
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/locales/es.js'));
32
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/fas/theme.js'));
33
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.js'));
34
 
35
 
36
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
37
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
38
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
39
 
40
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
41
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
42
 
43
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
44
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
45
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
46
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
47
 
48
 
49
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
50
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
51
 
52
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
53
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
54
 
55
 
56
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
57
 
58
 
59
$this->headStyle()->captureStart();
60
echo <<<CSS
61
 
62
 
63
#gridTableUsers {
64
    display: flex;
65
    flex-flow: column;
66
    width: 100%;
67
}
68
 
69
#gridTableUsers thead {
70
    flex: 0 0 auto;
71
}
72
 
73
#gridTableUsers tbody {
74
    flex: 1 1 auto;
75
    display: block;
76
    overflow-y: auto;
77
    overflow-x: hidden;
78
}
79
 
80
#gridTableUsers tr {
81
    width: 100%;
82
    display: table;
83
    table-layout: fixed;
84
}
6903 nelberth 85
.imagen-contaner{
86
	border:1px solid rgb(200,200,200);
87
	border-radius:5px;
6917 nelberth 88
	padding:10px;
89
	display:flex;
90
	flex-flow:column;
91
	align-items:center;
6903 nelberth 92
}
1 www 93
CSS;
94
$this->headStyle()->captureEnd();
95
 
96
$this->headLink()->captureStart();
97
 
98
$this->inlineScript()->captureStart();
99
echo <<<JS
100
    jQuery( document ).ready(function( $ ) {
101
 
102
        $.validator.setDefaults({
103
            debug: true,
104
            highlight: function(element) {
105
                $(element).addClass('is-invalid');
106
            },
107
            unhighlight: function(element) {
108
                $(element).removeClass('is-invalid');
109
            },
110
            errorElement: 'span',
111
            errorClass: 'error invalid-feedback',
112
            errorPlacement: function(error, element) {
113
                if(element.parent('.btn-file').length) {
114
                    error.insertAfter(element.parent().parent());
115
                } else if(element.parent('.toggle').length) {
116
                    error.insertAfter(element.parent().parent());
117
                } else {
118
                    error.insertAfter(element.parent());
119
                }
120
            }
121
        });
122
 
123
 
124
        $.fn.showFormErrorValidator = function(fieldname, errors) {
125
            var field = $(fieldname);
126
            if(field) {
127
                $(field).addClass('is-invalid');
128
 
129
 
130
                var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
131
                if(element.parent('.btn-file').length) {
132
                    error.insertAfter(element.parent().parent());
133
                } else if(element.parent('.toggle').length) {
134
                    error.insertAfter(element.parent().parent());
135
                } else {
136
                    error.insertAfter(element.parent());
137
                }
138
            }
139
        };
140
 
141
 
142
 
143
        var allowEdit   = $allowEdit;
144
        var allowDelete = $allowDelete;
145
        var allowUsers  = $allowUsers;
146
 
147
 
148
        var gridTable = $('#gridTable').dataTable( {
149
            'processing': true,
150
            'serverSide': true,
151
            'searching': true,
152
            'order': [[ 0, 'asc' ]],
153
            'ordering':  true,
154
            'ordenable' : true,
155
            'responsive': true,
156
            'select' : false,
157
        	'paging': true,
158
            'pagingType': 'simple_numbers',
159
 
160
    		'ajax': {
161
    			'url' : '$routeDatatable',
162
    			'type' : 'get',
163
                'data': function ( d ) {
164
                    d.topic_uuid = $('#form-filter #topic_uuid').val();
165
 
166
                },
167
                'beforeSend': function (request) {
168
                  NProgress.start();
169
                },
170
                'dataFilter': function(response) {
171
                    var response = jQuery.parseJSON( response );
172
 
173
                    var json                = {};
174
                    json.recordsTotal       = 0;
175
                    json.recordsFiltered    = 0;
176
                    json.data               = [];
177
 
178
                    if(response.success) {
179
                        $('#form-capsule-add').attr('action', response.data.link_add );
180
 
181
                        json.recordsTotal       = response.data.total;
182
                        json.recordsFiltered    = response.data.total;
183
                        json.data               = response.data.items;
184
                    } else {
185
                        $.fn.showError(response.data)
186
                    }
187
 
188
                    return JSON.stringify( json );
189
                }
190
    		},
191
            'language' : {
192
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
193
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
194
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
195
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
196
                'sInfo':           'LABEL_DATATABLE_SINFO',
197
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
198
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
199
                'sInfoPostFix':    '',
200
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
201
                'sUrl':            '',
202
                'sInfoThousands':  ',',
203
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
204
                'oPaginate': {
205
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
206
                    'sLast':     'LABEL_DATATABLE_SLAST',
207
                    'sNext':     'LABEL_DATATABLE_SNEXT',
208
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
209
                },
210
                'oAria': {
211
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
212
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
213
                },
214
            },
215
            'drawCallback': function( settings ) {
216
                NProgress.done();
217
                $('button.btn-delete').confirmation({
218
                    rootSelector: 'button.btn-delete',
219
                    title : 'LABEL_ARE_YOU_SURE',
220
                    singleton : true,
221
                    btnOkLabel: 'LABEL_YES',
222
                    btnCancelLabel: 'LABEL_NO',
223
                    onConfirm: function(value) {
224
                        action = $(this).data('href');
225
                        NProgress.start();
226
                        $.ajax({
227
                            'dataType'  : 'json',
228
                            'accept'    : 'application/json',
229
                            'method'    : 'post',
230
                            'url'       :  action,
231
                        }).done(function(response) {
232
                            if(response['success']) {
233
                                $.fn.showSuccess(response['data']);
234
                                gridTable.api().ajax.reload(null, false);
235
                            } else {
236
                                $.fn.showError(response['data']);
237
                            }
238
                        }).fail(function( jqXHR, textStatus, errorThrown) {
239
                            $.fn.showError(textStatus);
240
                        }).always(function() {
241
                            NProgress.done();
242
                        });
243
                    },
244
                });
245
            },
246
            'aoColumns': [
247
                { 'mDataProp': 'name' },
248
                { 'mDataProp': 'details' },
249
                { 'mDataProp': 'images' },
250
                { 'mDataProp': 'actions' },
251
    	    ],
252
            'columnDefs': [
253
                {
254
                    'targets': 0,
255
                    'className' : 'text-vertical-middle',
256
                },
257
                {
258
                    'targets': -3,
259
                    'orderable': false,
260
                    'render' : function ( data, type, row ) {
261
                        var s = '';
262
                        s += 'LABEL_STATUS: ' + data['status']  + '<br/>';
263
 
264
                         if(allowUsers && row['actions']['link_total_users']  ) {
265
                            s += 'LABEL_TOTAL_USERS: ' + data['total_users']  + ' <button class="btn btn-view-total-users" data-href="' + row['actions']['link_total_users'] + '" data-toggle="tooltip" title="LABEL_VIEW"><i class="fa fa-external-link"></i></button> <br>';
266
                         } else {
267
                            s += 'LABEL_TOTAL_USERS: ' + data['total_users']  + '<br/>';
268
                         }
269
                         if(allowUsers && row['actions']['link_total_users_actives']  ) {
270
                            s += 'LABEL_TOTAL_USERS_ACTIVE: ' + data['total_users_active']  + ' <button class="btn btn-view-total-users" data-href="' + row['actions']['link_total_users_actives'] + '" data-toggle="tooltip" title="LABEL_VIEW"><i class="fa fa-external-link"></i></button> <br>';
271
                         } else {
272
                            s += 'LABEL_TOTAL_USERS_ACTIVE: ' + data['total_users_active']  + '<br/>';
273
                         }
274
 
275
                        return s;
276
                    }
277
                },
278
                {
279
                    'targets': -2,
280
                    'orderable': false,
281
                    'render' : function ( data, type, row ) {
282
                        s = '';
283
 
6903 nelberth 284
						if( data['marketplace'] )  {
285
                            s = s + '&nbsp; <img class="btn-view-image-marketplace" data-href="' + data['marketplace'] + '" data-toggle="tooltip" src="'+data['marketplace']+'" title="LABEL_VIEW" style="width: 40px; object-fit: cover; height: 40px;" /> '
1 www 286
                        }  else {
287
                            s = s + '';
288
                        }
6903 nelberth 289
 
290
                        if( data['image'] )  {
291
                            s = s + '&nbsp; <img class="btn-view-image-app" data-href="' + data['image'] + '" data-toggle="tooltip" src="'+data['image']+'" title="LABEL_VIEW" style="width: 40px; object-fit: cover; height: 40px;" /> '
1 www 292
                        }  else {
293
                            s = s + '';
294
                        }
295
 
296
 
297
 
6903 nelberth 298
 
299
 
1 www 300
                        return s;
301
                    }
302
                },
303
 
304
 
305
                {
306
                    'targets': -1,
307
                    'orderable': false,
308
                    'render' : function ( data, type, row ) {
309
                        s = '';
310
 
311
                        if(allowEdit && data['link_edit']  ) {
312
                            s = s + '<button class="btn btn-info btn-sm btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button>&nbsp;';
313
                        }
314
                        if(allowDelete && data['link_delete']  ) {
315
                            s = s + '<button class="btn btn-danger btn-sm btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button>&nbsp;';
316
                        }
317
 
318
                        return s;
319
                    }
320
                }
321
              ],
322
        });
323
 
324
 
6823 nelberth 325
        var seleccionarCampo;
1 www 326
    var validatorAdd = $('#form-capsule-add').validate({
327
        debug: true,
328
        onclick: false,
329
        onkeyup: false,
330
        ignore: [],
331
        rules: {
332
            'name': {
333
                required: true,
334
                maxlength: 128,
335
            },
336
            'description': {
337
                updateCkeditor:function() {
338
                        CKEDITOR.instances.description_add.updateElement();
339
                },
340
                required: true
341
            },
342
           'file': {
343
                required: true,
344
            },
345
            'order' : {
346
                required: true,
347
                digits: true,
348
                min: 1,
349
                max: 250
350
            },
351
           'marketplace': {
6861 nelberth 352
                required: true,
1 www 353
            },
354
            'status' : {
355
                required: true,
356
            },
357
            'privacy' : {
358
                required: true,
359
            },
360
            'type' : {
361
                required: true,
362
            },
363
            'cost' : {
364
                required: function() {
365
                    return $('#form-capsule-add #type').val() == 's';
366
                },
367
                'number' : true,
368
                'min' : 0
369
            }
370
        },
371
        submitHandler: function(form)
372
        {
373
            var formdata = false;
374
            if (window.FormData){
375
                formdata = new FormData(form); //form[0]);
376
            }
377
 
6948 nelberth 378
            $('#boton_recortar').prop('disabled', true);
6859 nelberth 379
			NProgress.start();
1 www 380
            $.ajax({
381
                'dataType'  : 'json',
382
                'accept'    : 'application/json',
383
                'method'    : 'post',
384
                'url'       :  $('#form-capsule-add').attr('action'),
385
                'data'      :  formdata,
386
                'processData': false,
387
                'contentType': false,
388
            }).done(function(response) {
389
                if(response['success']) {
390
                    $.fn.showSuccess(response['data']);
6932 nelberth 391
                       console.log(response)
6703 nelberth 392
                    $('body, html').animate({scrollTop: '0px'}, 300);
393
					$('#content1').css('display','block');
394
                    $('.contenido').html('');
395
            		seleccionarCampo.css('display','none');
7000 nelberth 396
					$('#titleTypeImage').html('LABEL_IMAGE_MARKETPLACE')
6997 nelberth 397
					$('.marketplaceImg').attr('src', '')
6946 nelberth 398
					fileToggle=true;
1 www 399
                    gridTable.api().ajax.reload(null, false);
400
                } else {
401
                    validatorAdd.resetForm();
402
                    if(jQuery.type(response['data']) == 'string') {
403
                        $.fn.showError(response['data']);
404
                    } else  {
405
                        $.each(response['data'], function( fieldname, errors ) {
406
                            $.fn.showFormErrorValidator('#form-capsule-add #' + fieldname, errors);
407
                        });
408
                    }
409
                }
410
            }).fail(function( jqXHR, textStatus, errorThrown) {
6936 nelberth 411
				console.log(jqXHR)
1 www 412
                $.fn.showError(textStatus);
413
            }).always(function() {
6949 nelberth 414
				$('#boton_recortar').prop('disabled', false);
1 www 415
                NProgress.done();
416
            });
417
            return false;
418
        },
419
        invalidHandler: function(form, validator) {
420
 
421
        }
422
    });
423
 
424
    var validatorEdit  = $('#form-capsule-edit').validate({
425
        debug: true,
426
        onclick: false,
427
        onkeyup: false,
428
        ignore: [],
429
        rules: {
430
              'name': {
431
                required: true,
432
                maxlength: 128,
433
            },
434
            'description': {
435
                updateCkeditor:function() {
436
                        CKEDITOR.instances.description_edit.updateElement();
437
                },
438
                required: true
439
            },
440
           'file': {
6990 nelberth 441
                required: true,
1 www 442
            },
443
            'order' : {
444
                required: true,
445
                digits: true,
446
                min: 1,
447
                max: 250
448
            },
449
           'marketplace': {
6990 nelberth 450
                required: true,
1 www 451
            },
452
            'status' : {
453
                required: true,
454
            },
455
            'privacy' : {
456
                required: true,
457
            },
458
            'type' : {
459
                required: true,
460
            },
461
            'cost' : {
462
                required: function() {
463
                    return $('#form-capsule-edit #type').val() == 's';
464
                },
465
                'number' : true,
466
                'min' : 0
467
            }
468
        },
469
        submitHandler: function(form)
470
        {
471
            var formdata = false;
472
            if (window.FormData){
473
                formdata = new FormData(form); //form[0]);
474
            }
475
 
6992 nelberth 476
			$('#boton_recortar').prop('disabled', true);
477
			NProgress.start();
1 www 478
            $.ajax({
479
                'dataType'  : 'json',
480
                'accept'    : 'application/json',
481
                'method'    : 'post',
482
                'url'       :  $('#form-capsule-edit').attr('action'),
483
                'data'      :  formdata,
484
                'processData': false,
485
                'contentType': false,
486
            }).done(function(response) {
487
                if(response['success']) {
488
                    $.fn.showSuccess(response['data']);
6993 nelberth 489
					console.log(response)
6990 nelberth 490
					$('body, html').animate({scrollTop: '0px'}, 300);
491
					$('#content1').css('display','block');
492
                    $('.contenido').html('');
493
            		seleccionarCampo.css('display','none');
7000 nelberth 494
					$('#titleTypeImage').html('LABEL_IMAGE_MARKETPLACE')
6997 nelberth 495
					$('.marketplaceImg').attr('src', '')
6990 nelberth 496
					fileToggle=true;
6996 nelberth 497
					imagenEdit='';
1 www 498
                    gridTable.api().ajax.reload(null, false);
499
                } else {
500
                    validatorAdd.resetForm();
501
                    if(jQuery.type(response['data']) == 'string') {
502
                        $.fn.showError(response['data']);
503
                    } else  {
504
                        $.each(response['data'], function( fieldname, errors ) {
505
                            $.fn.showFormErrorValidator('#form-capsule-edit #' + fieldname, errors);
506
                        });
507
                    }
508
                }
509
            }).fail(function( jqXHR, textStatus, errorThrown) {
6993 nelberth 510
				console.log(jqXHR)
1 www 511
                $.fn.showError(textStatus);
512
            }).always(function() {
6996 nelberth 513
 
6992 nelberth 514
				$('#boton_recortar').prop('disabled', false);
1 www 515
                NProgress.done();
516
            });
517
            return false;
518
        },
519
        invalidHandler: function(form, validator) {
520
 
521
        }
522
    });
523
 
524
 
525
 
526
        $('body').on('click', '.btn-view-image-marketplace', function(e) {
527
            e.preventDefault();
528
 
529
            $('#image-marketplace').attr('src', $(this).data('href'));
530
            $('#modalAppMarkeplate').modal('show');
531
            return false;
532
        });
533
 
534
        $('body').on('click', '.btn-view-image-app', function(e) {
535
            e.preventDefault();
536
 
537
            $('#image-app').attr('src', $(this).data('href'));
538
            $('#modalImageApp').modal('show');
539
            return false;
540
        });
541
 
542
        $('#form-capsule-add #order').inputNumberFormat({decimal: 0});
543
 
544
 
545
 
546
 
547
        $('body').on('click', 'button.btn-add', function(e) {
548
            e.preventDefault();
549
 
550
            $('#form-capsule-add #name').val('');
551
            $('#form-capsule-add #order').val('1');
552
 
553
            $('#form-capsule-add #privacy').val('');
554
            $('#form-capsule-add #status').val('');
555
            $('#form-capsule-add #cost').val('');
556
            $('#form-capsule-add #form-row-cost').hide();
557
 
558
            CKEDITOR.instances.description_add.setData('');
559
            validatorAdd.resetForm();
560
 
6694 nelberth 561
            $('body, html').animate({scrollTop: '0px'}, 300);
562
		    $('#content1').css('display','none');
563
            seleccionarCampo= $('#modalCapsuleAdd');
564
            seleccionarCampo.css('display','block')
565
		    iniciarEditor(seleccionarCampo)
1 www 566
            return false;
567
        });
568
 
569
 
570
        $('#form-capsule-edit #order').inputNumberFormat({decimal: 0});
571
 
6859 nelberth 572
 
1 www 573
 
6991 nelberth 574
 
1 www 575
 
576
        $('body').on('click', 'button.btn-edit', function(e) {
577
            e.preventDefault();
7045 nelberth 578
			NProgress.start();
1 www 579
            var url = $(this).data('href');
580
            $.ajax({
581
                'dataType'  : 'json',
582
                'accept'    : 'application/json',
583
                'method'    : 'get',
584
                'url'       :  url,
585
            }).done(function(response) {
586
                if(response['success']) {
6980 nelberth 587
					console.log(response)
1 www 588
                    $('#form-capsule-edit').attr('action',url);
589
                    $('#form-capsule-edit #name').val(response['data']['name']);
590
                    $('#form-capsule-edit #order').val(response['data']['order']);
591
                    $('#form-capsule-edit #privacy').val(response['data']['privacy']);
592
                    $('#form-capsule-edit #type').val(response['data']['type']);
593
                    $('#form-capsule-edit #status').val(response['data']['status']);
594
 
595
                    if('s' == response['data']['type']) {
596
                        $('#form-capsule-edit #form-row-cost').show();
597
                        $('#form-capsule-edit #cost').val(response['data']['cost']);
598
                    } else {
599
                        $('#form-capsule-edit #form-row-cost').hide();
600
                        $('#form-capsule-edit #cost').val('');
601
                    }
602
 
603
                    CKEDITOR.instances.description_edit.setData(response['data']['description']);
604
                    validatorEdit.resetForm();
6979 nelberth 605
					 fileToggle=true;
6975 nelberth 606
					$('body, html').animate({scrollTop: '0px'}, 300);
607
					$('#content1').css('display','none');
608
                    seleccionarCampo= $('#modalCapsuleEdit');
609
                    seleccionarCampo.css('display','block')
6984 nelberth 610
					imagenEdit=response['data']['image'];
6975 nelberth 611
		            iniciarEditor(seleccionarCampo,response['data']['marketplace'])
15027 stevensc 612
 
1 www 613
                } else {
614
                    validatorEdit.resetForm();
615
                    if(jQuery.type(response['data']) == 'string') {
616
                        $.fn.showError(response['data']);
617
                    } else  {
618
                        $.each(response['data'], function( fieldname, errors ) {
619
                            $.fn.showFormErrorValidator('#form-capsule-edit #' + fieldname, errors);
620
                        });
621
                    }
622
                }
623
            }).fail(function( jqXHR, textStatus, errorThrown) {
624
                $.fn.showError(textStatus);
625
            }).always(function() {
626
                NProgress.done();
627
            });
628
        });
629
 
6886 nelberth 630
 
1 www 631
 
632
 
8290 stevensc 633
        CKEDITOR.replace('description_add', {
634
			toolbar: [
635
                    { name: 'editing', items: ['Scayt'] },
636
                    { name: 'links', items: ['Link', 'Unlink'] },
637
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
638
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
639
                    '/',
640
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
641
                    { name: 'styles', items: ['Styles', 'Format'] },
642
                    { name: 'tools', items: ['Maximize'] }
643
                ],
644
                removePlugins: 'elementspath,Anchor',
645
                heigth: 100
646
		});
647
        CKEDITOR.replace('description_edit', {
648
			toolbar: [
649
                    { name: 'editing', items: ['Scayt'] },
650
                    { name: 'links', items: ['Link', 'Unlink'] },
651
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
652
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
653
                    '/',
654
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
655
                    { name: 'styles', items: ['Styles', 'Format'] },
656
                    { name: 'tools', items: ['Maximize'] }
657
                ],
658
                removePlugins: 'elementspath,Anchor',
659
                heigth: 100
660
		});
1 www 661
 
662
        $('#form-capsule-add #type').change(function(e) {
663
            e.preventDefault();
664
 
665
            if('s' == $(this).val()) {
666
                $('#form-capsule-add #form-row-cost').show();
667
            } else {
668
                $('#form-capsule-add #cost').val(0);
669
                $('#form-capsule-add #form-row-cost').hide();
670
            }
671
 
672
        });
673
 
674
        $('#form-capsule-edit #type').change(function(e) {
675
            e.preventDefault();
676
 
677
            if('s' == $(this).val()) {
678
                $('#form-capsule-edit #form-row-cost').show();
679
            } else {
680
                $('#form-capsule-edit #cost').val(0);
681
                $('#form-capsule-edit #form-row-cost').hide();
682
            }
683
 
684
        });
685
 
686
        $('#form-capsule-add #order').inputNumberFormat({decimal: 0});
687
        $('#form-capsule-add #cost').inputNumberFormat({decimal: 2});
688
 
689
        $('#form-filter #topic_uuid').change(function(e) {
690
            e.preventDefault();
691
 
692
            gridTable.api().ajax.reload(null, false);
693
 
694
        });
695
 
696
 
697
 
698
 
699
 
700
    $('body').on('click', 'button.btn-view-total-users', function(e) {
701
        e.preventDefault();
702
 
703
        var href = $(this).data('href');
704
        NProgress.start();
705
        $.ajax({
706
            'dataType'  : 'json',
707
            'accept'    : 'application/json',
708
            'method'    : 'get',
709
            'url'       : href,
710
        }).done(function(response) {
711
            if(response['success']) {
712
 
713
                $('#table-users-topic').val(response['data']['topic']);
714
      			$('#table-users-capsule').val(response['data']['capsule']);
715
 
716
                $('#gridTableUsers tbody').empty();
717
 
718
                $.each(response['data']['items'], function(index, item) {
719
 
720
                    console.log(item);
721
 
722
                    var s = '<tr>';
723
                    s = s + '<td>' + item['first_name'] + '</td>';
724
                    s = s + '<td>' + item['last_name'] + '</td>';
725
                    s = s + '<td>' + item['email'] + '</td>';
726
 
727
                    s = s + '<td>';
728
                    if(item['details']['access']) {
729
                        s = s + 'LABEL_ACCESS : ' + item['details']['access'] + '<br>';
730
                    }
731
                    if(item['details']['paid_from']) {
732
                        s = s + 'LABEL_PAID_FROM : ' + item['details']['paid_from'] + '<br>';
733
                    }
734
                    if(item['details']['paid_to']) {
735
                        s = s + 'LABEL_PAID_TO : ' + item['details']['paid_to'] + '<br>';
736
                    }
737
 
738
                    s = s + '</td>';
739
                    s = s + '</tr>';
740
 
741
                    $('#gridTableUsers tbody').append(s);
742
 
743
 
744
                });
745
 
746
                $('#notificationUsersModal').modal('show');
747
 
748
            } else {
749
                $.fn.showError(response['data']);
750
 
751
            }
752
        }).fail(function( jqXHR, textStatus, errorThrown) {
753
            $.fn.showError(textStatus);
754
        }).always(function() {
755
 
756
            NProgress.done();
757
        });
758
        return false;
759
 
760
    });
761
    $('body').on('click', 'button.btn-refresh', function(e) {
762
        e.preventDefault();
763
        gridTable.api().ajax.reload(null, false);
764
    });
6682 nelberth 765
       	/*Script del editor (Aqui comienza el cielo y la tierra) */
6863 nelberth 766
 
767
		var fileToggle=true;
6886 nelberth 768
		$('body').on('click', '#ir_atras', function(e) {
769
            e.preventDefault();
770
			if(fileToggle){
6985 nelberth 771
				imagenEdit='';
6886 nelberth 772
            	$('body, html').animate({scrollTop: '0px'}, 300);
773
				$('#content1').css('display','block');
774
           		seleccionarCampo.css('display','none');
775
            	$('.contenido').html('');
6997 nelberth 776
				$('.marketplaceImg').attr('src', '')
6886 nelberth 777
			}else{
7000 nelberth 778
				$('#titleTypeImage').html('LABEL_IMAGE_MARKETPLACE')
6997 nelberth 779
				$('.marketplaceImg').attr('src', '')
6964 nelberth 780
				fileToggle=true;
6890 nelberth 781
				iniciarEditor(seleccionarCampo,imagenServidorNoticia,false)
6964 nelberth 782
 
6886 nelberth 783
			}
784
            return false;
785
        });
6984 nelberth 786
		var imagenEdit='';
6682 nelberth 787
		var imagenServidorNoticia;
788
		var scroll_altura,viente;
789
		var nombre_user = $(".perfil_u_nombre").text();
790
		var primer_nombre = nombre_user.split(" ")[0];
11027 nelberth 791
		var nuevoHtmlImagen='<div class="articulo_noticia animated fadeIn"> <div class="pasos"> <div class="titulo_pasos animated fadeInDown delay-04 fast">LABEL_STEP_1</div><div class="paso_opcion"> <div class="responsing_cut"> <div class="icon_cut"><span class="fa fa-scissors"></span></div><div class="contenido_cut"> <div class="animated fadeInRight delay-04 fast"> <div> <div class="titulo_cut"> <div>LABEL_CUT</div><div class="fa fa-times" id="cerrar_cut_modal"></div></div><div class="opcion_editor recortar10"> <div class="recortar_texto">LABEL_CUT</div><div id="blockCelda"><span class="fa fa-unlock"></span></div></div></div></div></div></div><div class="responsing_text"> <div class="icon_text"><span class="fa fa-text-width"></span></div><div class="contenido_text"> <div class="animated fadeInRight delay-04 fast"> <div class="texto"> <div class="titulo_text"> <div>LABEL_TEXT</div><div class="fa fa-times" id="cerrar_text_modal"></div></div><div class="fonts mb-20"><select name="fuentes" id="selectFuente" class="select-custom mr-2"><option value="arial" selected>LABEL_FONT_ARIAL</option><option value="calibri">LABEL_FONT_CALIBRI</option><option value="forte">LABEL_FONT_FORTE</option><option value="impact">LABEL_FONT_IMPACT</option><option value="jokerman">LABEL_FONT_JOKERMAN</option><option value="mv boli">LABEL_FONT_MV_BOLI</option><option value="times new roman">LABEL_FONT_TIMES_NEW_ROMAN</option><option value="verdana">LABEL_FONT_VERDANA</option><option value="vivaldi">LABEL_FONT_VIVALDI</option></select><input type="number" class="" data-tooltip="Tamaño de la letra" name="" id="font-size" max="500" min="1" step="1" value="48"/></div><div class="fonts mb-20"> <div class="font" id="negritas" data-tooltip="Negritas"><i class="fa fa-bold" aria-hidden="true"></i></div><div class="font" id="italic" data-tooltip="Letra Cursiva"><i class="fa fa-italic" aria-hidden="true"></i></div><div class="color_letra font"><label>A</label><input type="color" class="" data-tooltip="Color de la letra" name="" id="color" value="#ffffff"/></div><div class="font fa" data-tooltip="Sombra de la letra" id="shadow">S</div><div class="font" id="rectangulo" data-tooltip="Fondo de la letra"> <div class="rectangulo">F</div></div></div><div class="color_fondo_cuadro mb-20 flex-column" style="display:none"> <div class="w-100 d-flex justify-content-between border-bottom"><label for="colorrect" class="font-weight-normal d-flex align-items-center" style="margin:0 !important">LABEL_COLOR_BACKGROUND: </label><input type="color" name="" id="colorrect" value="#000000" style="width:30px" data-tooltip="Color del fondo" class="mr-2"/></div><div class="d-flex flex-column"><label for="opacidad" class="font-weight-normal mt-2">LABEL_BACKGROUND_TRANSPARENCY</label><input type="range" id="opacidad" max="100" min="1" step="1" value="100" ></div></div><input id="texto_input" type="text" name="texto" placeholder="LABEL_ADD_TEXT_HERE"/> </div></div></div></div><div class="responsing_filtros"> <div class="icon_filter"><span class="fa fa-eyedropper"></span></div><div class="contenido_filter"> <div class="titulo_filtro mb-20"> <div>LABEL_FILTERS</div><div class="fa fa-times" id="cerrar_filter_modal"></div></div><div class="fonts mb-20"> <select name="filtros" id="selectFiltro" class="select-custom"><option class="opcion_editor" value="normal">LABEL_FILTER_NORMAL</option><option class="opcion_editor" value=".5,1.3,1.31,1.33,1.38">LABEL_FILTER_NIGHT</option><option class="opcion_editor" value=".7,1.1,1.64,1.66,1.50">LABEL_FILTER_SAINT_ANA</option><option class="opcion_editor" value=".75,1,1.66,1.60,1.51">LABEL_FILTER_CREAM</option><option class="opcion_editor" value=".7,1.2,1.49,1.49,1.6">LABEL_FILTER_MAGIC</option><option class="opcion_editor" value=".7,1.2,1.60,1.66,1.58">LABEL_FILTER_RELIEF</option><option class="opcion_editor" value=".9,.9,1.45,1.54,1.54">LABEL_FILTER_LIGHT</option><option class="opcion_editor" value="1,1.5,1,1,1">LABEL_FILTER_SATURATION</option><option class="opcion_editor" value=".9,1.3,1,1,1">LABEL_FILTER_RETOUCH</option><option class="opcion_editor" value=".8,1,1.6,1.45,1.49">LABEL_FILTER_ORANGE</option><option class="opcion_editor" value=".8,.75,1.60,1.66,1.58">LABEL_FILTER_WIND</option><option class="opcion_editor" value=".8,.9,1.66,1.43,1.28">LABEL_FILTER_DESERT</option><option class="opcion_editor" value=".85,.75,1.47,1.66,1.54">LABEL_FILTER_FOREST</option><option class="opcion_editor" value=".8,.8,1.71,1.64,1.58">LABEL_FILTER_TOWN</option><option class="opcion_editor" value=".8,1.2,1.24,.99,1">LABEL_FILTER_PINK</option><option class="opcion_editor" value=".9,1.1,1.33,1.19,.91">LABEL_FILTER_HISTORY</option><option class="opcion_editor" value="1,1,gris">LABEL_FILTER_GRAY</option><option class="opcion_editor" value=".8,1.5,gris">LABEL_FILTER_OLD_PICTURE</option><option class="opcion_editor" value=".9,1.2,26,-12,0,2">LABEL_FILTER_CHARMING</option><option class="opcion_editor" value="1.1,1.4,40,12,-6,2">LABEL_FILTER_EMOTION</option><option class="opcion_editor" value=".9,1.32,56,47,17,2">LABEL_FILTER_BEIGE</option><option class="opcion_editor" value=".87,1.19,55,37,23,2">LABEL_FILTER_FINE</option><option class="opcion_editor" value="1.2,.9,67,13,-23,2">LABEL_FILTER_LORD</option><option class="opcion_editor" value="1.2,1.2,35,7,18,2">LABEL_FILTER_70S</option><option class="opcion_editor" value=".92,1.23,-11,11,11,2">LABEL_FILTER_TREE</option><option class="opcion_editor" value=" 1,1.4,-3,-1,-12,2">LABEL_FILTER_SUMMER</option><option class="opcion_editor" value=".85,1.26,-15,2,-1,2">LABEL_FILTER_COLD_WEATHER</option><option class="opcion_editor" value="1,1.4,5,12,1,2">LABEL_FILTER_ANGELS</option><option class="opcion_editor" value=".9,1.2,43,-17,-55,2">LABEL_FILTER_HOT</option><option class="opcion_editor" value="1,1.29,29,26,17,2">LABEL_FILTER_FALL</option><option class="opcion_editor" value=".85,1.3,43,25,-11,2">LABEL_FILTER_MARCH</option><option class="opcion_editor" value=".8,1.25,31,41,12,2">LABEL_FILTER_PEAR</option><option class="opcion_editor" value="1,1.36,4,5,1,2">LABEL_FILTER_COMMON</option><option class="opcion_editor" value=".9,1.3,37,-25,1,2">LABEL_FILTER_GOLD</option><option class="opcion_editor" value="1.1,1.3,-47,-42,-30,2">LABEL_FILTER_GOTHIC</option><option class="opcion_editor" value="1,1.4,-5,42,11,2">LABEL_FILTER_FORESTRY</option><option class="opcion_editor" value=".9,1.2,-5,-7,4,2">LABEL_FILTER_MOON</option><option class="opcion_editor" value="1.1,1.3,-1,-1,26,2">LABEL_FILTER_PARTY</option> </select> </div></div></div><div class="volver"><span class="icon-undo"></span>LABEL_START_OVER</div><div class="paso_1 paso animated bounceInDown delay-04 fast">1</div><div class="paso_2 a1 animated bounceInDown delay-06 fast">2</div><div class="paso_2 b1 animated bounceInDown delay-08 fast">3</div></div></div><div class="editor_imagenes"> <div class="fondo_oscuro"></div><div class="editor_imagenes2 "> <div> <div class="canvas_imagen"> <div class="canvas recortar"> <div class="canvas_subir d-flex flex-column" id="imagen_noticia"><div>LABEL_DRAG_IMAGE_HERE_OR </div><label class="font-weight-normal mt-2" style="font-size:0.6em"for="imagen_noticia_file"> LABEL_UPLOAD_FILE_IMAGE <div class="ml-2 btn btn-primary btn-sm">LABEL_SELECT_IMAGE</div></label> <input style="display:none" type="file" id="imagen_noticia_file" accept="image/x-png,image/jpeg"></div></div></div><div class="botones_dimenciones"> <div class="scale"> <div class="dimenciones"> <div id="ancho">1240px</div><div>x</div><div id="alto">720px</div></div><div class="porciento"> <div id="menos_scale"><span class="icon-minus fa fa-minus"></span></div><div class="ps"> <ul class="cantidades_scale"> <li data-scale="2" class="as">200%</li><li data-scale="1" class="as">100%</li><li data-scale="0.75" class="as">75%</li><li data-scale="0.5" class="as">50%</li><li data-scale="0.25" class="as">25%</li></ul> <div id="porciento_scale">50%</div></div><div id="mas_scale"><span class="icon-plus fa fa-plus"></span></div></div></div><div class="botones"><button class="boton_normal" id="ir_atras">LABEL_GO_BACK</button><button class="boton_normal" id="boton_recortar">LABEL_DATATABLE_SNEXT</button></div></div></div><div class="modificar animated fadeInRight delay-04 fast escalar"> <div> <div class="titulo_recortar"><span class="icon-ungroup fa fa-scissors mb-20"></span>LABEL_CUT</div><div class="opcion_editor recortar10"> <div class="recortar_texto">LABEL_CUT</div><div id="blockCelda"><span class="fa fa-unlock"></span></div></div></div><div class="texto"> <div class="mb-20"> <div class="titulo_texto "><span class="icon-plus fa fa-text-width"></span>LABEL_TEXT</div></div><div class="fonts mb-20"> <select name="fuentes" id="selectFuente" class="select-custom mr-2"> <option value="arial" selected>LABEL_FONT_ARIAL</option> <option value="calibri">LABEL_FONT_CALIBRI</option> <option value="forte">LABEL_FONT_FORTE</option> <option value="impact">LABEL_FONT_IMPACT</option> <option value="jokerman">LABEL_FONT_JOKERMAN</option> <option value="mv boli">LABEL_FONT_MV_BOLI</option> <option value="times new roman">LABEL_FONT_TIMES_NEW_ROMAN</option> <option value="verdana">LABEL_FONT_VERDANA</option> <option value="vivaldi">LABEL_FONT_VIVALDI</option> </select> <input type="number" class="" data-tooltip="Tamaño de la letra" name="" id="font-size" max="500" min="1" step="1" value="48"/> </div><div class="fonts mb-20"> <div class="font" id="negritas" data-tooltip="Negritas"><i class="fa fa-bold" aria-hidden="true"></i></div><div class="font" id="italic" data-tooltip="Letra Cursiva"><i class="fa fa-italic" aria-hidden="true"></i></div><div class="color_letra font"><label>A</label><input type="color" class="" data-tooltip="Color de la letra" name="" id="color" value="#ffffff"/></div><div class="font fa" data-tooltip="Sombra de la letra" id="shadow">S</div><div class="font" id="rectangulo" data-tooltip="Fondo de la letra"> <div class="rectangulo">F</div></div></div><div class="color_fondo_cuadro mb-20 flex-column" style="display:none"> <div class="w-100 d-flex justify-content-between border-bottom"><label for="colorrect" class="font-weight-normal d-flex align-items-center" style="margin:0 !important">LABEL_COLOR_BACKGROUND: </label><input type="color" name="" id="colorrect" value="#000000" style="width:30px" data-tooltip="Color del fondo" class="mr-2"/></div><div class="d-flex flex-column"><label for="opacidad" class="font-weight-normal mt-2">LABEL_BACKGROUND_TRANSPARENCY</label><input type="range" id="opacidad" max="100" min="1" step="1" value="100" ></div></div><input id="texto_input" type="text" name="texto" placeholder="LABEL_ADD_TEXT_HERE"/> <div class="mb-20"> <div class="titulo_filtro"><span class="icon-eyedropper fa fa-eyedropper"></span>LABEL_FILTERS</div></div><div class="fonts mb-20"> <select name="filtros" id="selectFiltro" class="select-custom selectFiltro"><option class="opcion_editor" value="normal" >LABEL_FILTER_NORMAL</option><option class="opcion_editor" value=".5,1.3,1.31,1.33,1.38">LABEL_FILTER_NIGHT</option><option class="opcion_editor" value=".7,1.1,1.64,1.66,1.50">LABEL_FILTER_SAINT_ANA</option><option class="opcion_editor" value=".75,1,1.66,1.60,1.51">LABEL_FILTER_CREAM</option><option class="opcion_editor" value=".7,1.2,1.49,1.49,1.6">LABEL_FILTER_MAGIC</option><option class="opcion_editor" value=".7,1.2,1.60,1.66,1.58">LABEL_FILTER_RELIEF</option><option class="opcion_editor" value=".9,.9,1.45,1.54,1.54">LABEL_FILTER_LIGHT</option><option class="opcion_editor" value="1,1.5,1,1,1">LABEL_FILTER_SATURATION</option><option class="opcion_editor" value=".9,1.3,1,1,1">LABEL_FILTER_RETOUCH</option><option class="opcion_editor" value=".8,1,1.6,1.45,1.49">LABEL_FILTER_ORANGE</option><option class="opcion_editor" value=".8,.75,1.60,1.66,1.58">LABEL_FILTER_WIND</option><option class="opcion_editor" value=".8,.9,1.66,1.43,1.28">LABEL_FILTER_DESERT</option><option class="opcion_editor" value=".85,.75,1.47,1.66,1.54">LABEL_FILTER_FOREST</option><option class="opcion_editor" value=".8,.8,1.71,1.64,1.58">LABEL_FILTER_TOWN</option><option class="opcion_editor" value=".8,1.2,1.24,.99,1">LABEL_FILTER_PINK</option><option class="opcion_editor" value=".9,1.1,1.33,1.19,.91">LABEL_FILTER_HISTORY</option><option class="opcion_editor" value="1,1,gris">LABEL_FILTER_GRAY</option><option class="opcion_editor" value=".8,1.5,gris">LABEL_FILTER_OLD_PICTURE</option><option class="opcion_editor" value=".9,1.2,26,-12,0,2">LABEL_FILTER_CHARMING</option><option class="opcion_editor" value="1.1,1.4,40,12,-6,2">LABEL_FILTER_EMOTION</option><option class="opcion_editor" value=".9,1.32,56,47,17,2">LABEL_FILTER_BEIGE</option><option class="opcion_editor" value=".87,1.19,55,37,23,2">LABEL_FILTER_FINE</option><option class="opcion_editor" value="1.2,.9,67,13,-23,2">LABEL_FILTER_LORD</option><option class="opcion_editor" value="1.2,1.2,35,7,18,2">LABEL_FILTER_70S</option><option class="opcion_editor" value=".92,1.23,-11,11,11,2">LABEL_FILTER_TREE</option><option class="opcion_editor" value=" 1,1.4,-3,-1,-12,2">LABEL_FILTER_SUMMER</option><option class="opcion_editor" value=".85,1.26,-15,2,-1,2">LABEL_FILTER_COLD_WEATHER</option><option class="opcion_editor" value="1,1.4,5,12,1,2">LABEL_FILTER_ANGELS</option><option class="opcion_editor" value=".9,1.2,43,-17,-55,2">LABEL_FILTER_HOT</option><option class="opcion_editor" value="1,1.29,29,26,17,2">LABEL_FILTER_FALL</option><option class="opcion_editor" value=".85,1.3,43,25,-11,2">LABEL_FILTER_MARCH</option><option class="opcion_editor" value=".8,1.25,31,41,12,2">LABEL_FILTER_PEAR</option><option class="opcion_editor" value="1,1.36,4,5,1,2">LABEL_FILTER_COMMON</option><option class="opcion_editor" value=".9,1.3,37,-25,1,2">LABEL_FILTER_GOLD</option><option class="opcion_editor" value="1.1,1.3,-47,-42,-30,2">LABEL_FILTER_GOTHIC</option><option class="opcion_editor" value="1,1.4,-5,42,11,2">LABEL_FILTER_FORESTRY</option><option class="opcion_editor" value=".9,1.2,-5,-7,4,2">LABEL_FILTER_MOON</option><option class="opcion_editor" value="1.1,1.3,-1,-1,26,2">LABEL_FILTER_PARTY</option> </select> </div></div></div></div></div></div><dav class="fixed_noticia"></dav><dav class="cuadro_noticias animated bounceInUp delay-04" id="cuadro_noticias"> <dav class="relative"> <div class="titulo_topico">LABEL_TITLE_TOPIC</div><canvas class="imagen_noticias" id="imagen_noticias" width="320" height="480"></canvas> </dav> <div class="progreso d-flex align-items-center justify-content-between"><progress value="0" max="100"></progress><span class="ml-2">0.0%</span></div></dav>'
792
 
6966 nelberth 793
		var pw=420,ph=320;
6682 nelberth 794
		$(document).on("click", ".info_noticia", function(e){
795
			imagenServidorNoticia = elemento.toDataURL("image/jpeg", 1.0);
6863 nelberth 796
			if(fileToggle){
6864 nelberth 797
				e.preventDefault();
6863 nelberth 798
				setTimeout(function(){
6972 nelberth 799
 
6997 nelberth 800
					$('.marketplaceImg').attr('src', imagenServidorNoticia)
7000 nelberth 801
					$('#titleTypeImage').html('LABEL_IMAGE')
6863 nelberth 802
					fileToggle=false;
6984 nelberth 803
					if(imagenEdit==""){
804
						iniciarEditor(seleccionarCampo)
805
					}else{
806
						iniciarEditor(seleccionarCampo,imagenEdit)
807
					}
6925 nelberth 808
 
6863 nelberth 809
				},$('.marketplace').val(imagenServidorNoticia.split(',')[1]));
810
			}else{
811
				$('.file').val(imagenServidorNoticia.split(',')[1]);
6946 nelberth 812
 
6863 nelberth 813
			}
814
 
6682 nelberth 815
			console.log($('.file').val())
6874 nelberth 816
			console.log($('.marketplace').val())
6682 nelberth 817
			$(".c1").addClass("paso");
1 www 818
 
6682 nelberth 819
 
820
		})
8582 nelberth 821
		var edit;
6889 nelberth 822
		function iniciarEditor(campo, image='',load=true){
6682 nelberth 823
		 cortar=false;
824
		recorte_listo=false;
825
		texto="";
826
		seis=true;
827
		color="#ffffff";
828
		texto_listo=false,siete=false;
829
		uno=true;
830
		size=48;
831
		cinco=true;
11038 nelberth 832
		blockCelda=false;
6952 nelberth 833
		if(fileToggle){
6970 nelberth 834
			pw=420; ph=320;
835
			recorte=ph/pw;
6952 nelberth 836
		}else{
6970 nelberth 837
			pw=320; ph=480;
838
			recorte=ph/pw;
6952 nelberth 839
		}
840
 
6926 nelberth 841
		xf=pw,yf =ph;
6682 nelberth 842
		negritas=false, bold="";
843
		shadow = true, nueve=true;
844
		italic=false, ita="";
845
		rectangulo=false, diez=false;
846
     	fontfamily="Arial";
847
     	r=0,g=0,b=0,a=1;
848
		window.clearInterval(editorNoticia);
849
		setTimeout(function(){
6959 nelberth 850
			if(fileToggle){
851
				$('#imagen_noticias').css({
852
					'height': '320px',
853
    				'width': '420px',
854
				})
6999 nelberth 855
				$('.cuadro_noticias').addClass('tienda')
6959 nelberth 856
 
6965 nelberth 857
			}else{
858
				$('#imagen_noticias').css({
859
					'height': '480px',
860
    				'width': '320px',
861
				})
6999 nelberth 862
				$('.cuadro_noticias').removeClass('tienda')
6959 nelberth 863
			}
6971 nelberth 864
			console.log(ph+'  '+pw)
6682 nelberth 865
			scroll_altura=$(".articulo_noticia").offset().top-110;
866
			anchoFondoOscuro = $(".articulo_noticia").width();
867
			altoFondoOscuro = $(".editor_imagenes").height();
868
 
6889 nelberth 869
		},navegacion(nuevoHtmlImagen,campo,image,load));
6682 nelberth 870
 
871
		}
872
 
873
		$(document).on("click", ".volver", function(){
874
		var nombre_user = $(".perfil_u_nombre").text();
875
		var primer_nombre = nombre_user.split(" ")[0];
876
		 cortar=false;
877
		cinco=true;
878
		recorte_listo=false;
879
		texto="";
880
		seis=true;
881
		color="#ffffff";
882
		texto_listo=false,siete=false;
883
		uno=true;
884
		size=48;
6960 nelberth 885
		if(fileToggle){
886
			pw=420, ph=320;
6967 nelberth 887
			recorte=ph/pw
6960 nelberth 888
		}else{
889
			pw=320, ph=480;
6967 nelberth 890
			recorte=ph/pw
6960 nelberth 891
		}
6926 nelberth 892
		xf=pw,yf =ph;
11038 nelberth 893
		blockCelda=false;
6682 nelberth 894
		negritas=false, bold="";
895
		shadow = true, nueve=true;
896
		italic=false, ita="";
897
		rectangulo=false, diez=false;
898
     	fontfamily="Arial";
899
     	r=0,g=0,b=0,a=1;
900
		 var imagenServidorNoticia;
901
         console.log(seleccionarCampo)
902
		window.clearInterval(editorNoticia);
903
		setTimeout(function(){
6960 nelberth 904
			if(fileToggle){
905
				$('#imagen_noticias').css({
906
					'height': '320px',
907
    				'width': '420px',
908
				})
11258 nelberth 909
				$('.cuadro_noticias').addClass('tienda')
6960 nelberth 910
 
11258 nelberth 911
			}else{
912
				$('#imagen_noticias').css({
913
					'height': '480px',
914
    				'width': '320px',
915
				})
916
				$('.cuadro_noticias').removeClass('tienda')
6960 nelberth 917
			}
6682 nelberth 918
			scroll_altura=$(".articulo_noticia").offset().top-110;
919
			anchoFondoOscuro = $(".articulo_noticia").width();
920
			altoFondoOscuro = $(".editor_imagenes").height();
921
 
922
		},navegacion(nuevoHtmlImagen,seleccionarCampo));
923
 
924
		})
925
 
6889 nelberth 926
		function navegacion(nuevoHtmlImagen,campo,image='',load=true){
6682 nelberth 927
                selectorElementoName=campo.find('#name')
8583 nelberth 928
 
6824 nelberth 929
                selectorElementoEditor=campo.find('#contenido');
8584 nelberth 930
				edit=true;
6682 nelberth 931
				if(image!=''){
8585 nelberth 932
					edit=false;
6889 nelberth 933
					if(load){
8585 nelberth 934
 
8583 nelberth 935
 
6888 nelberth 936
						const getBase64FromUrl = async (url) => {
937
							const data = await fetch(url);
938
							const blob = await data.blob();
939
							return new Promise((resolve) => {
940
								const reader = new FileReader();
941
								reader.readAsDataURL(blob);
942
								reader.onloadend = function() {
943
								const base64data = reader.result;
944
								resolve(base64data);
945
								}
946
							});
947
						}
8583 nelberth 948
 
6888 nelberth 949
						getBase64FromUrl(image).then(function(e){
950
							selectorElementoName.trigger('change');
951
							$(".volver").css("display","block")
952
							$(".a1").addClass("paso");
953
							$(".titulo_pasos").html("LABEL_STEP_2");
954
							setTimeout(function(){
955
								recorte_listo=true;
956
								$(".fondo_oscuro").css("display","none");
6989 nelberth 957
								if(fileToggle){
7000 nelberth 958
									$("#boton_recortar").removeClass("recortar").text("LABEL_ATTACH_IMAGE").addClass("info_noticia");
6989 nelberth 959
									}else{
960
									$("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
961
								}
6888 nelberth 962
								$(".recortar10").removeClass("recortar");
963
								$(".canvas").removeClass("recortar");
964
								$(".b1").addClass("paso");
965
								$(".titulo_pasos").html("LABEL_STEP_3");
966
								if(texto!=""){
967
									seis=true;
968
									siete=true;
969
								}
970
								cinco=true;
971
								dos=true;
972
								cuatro=true;
973
								actualizar();
974
 
975
							},editorNoticia(e));
976
 
977
 
978
						})
6891 nelberth 979
						setTimeout(function(){
7000 nelberth 980
							$(".canvas_subir").html('<span class="icon-plus fa fa-spinner"></span> LABEL_LOADING...')
6891 nelberth 981
							selectorElementoName.trigger('change');
982
						},selectorElementoEditor.html(nuevoHtmlImagen));
6888 nelberth 983
					}else{
6682 nelberth 984
						selectorElementoName.trigger('change');
6891 nelberth 985
						setTimeout(function(){
6888 nelberth 986
							$(".volver").css("display","block")
987
							$(".a1").addClass("paso");
988
							$(".titulo_pasos").html("LABEL_STEP_2");
989
							setTimeout(function(){
6905 nelberth 990
								recorte_listo=true;
6888 nelberth 991
								$(".fondo_oscuro").css("display","none");
6987 nelberth 992
								if(fileToggle){
993
 
7000 nelberth 994
									$("#boton_recortar").removeClass("recortar").text("LABEL_ATTACH_IMAGE").addClass("info_noticia");
6988 nelberth 995
								}else{
6987 nelberth 996
									$("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
997
 
998
								}
6888 nelberth 999
								$(".recortar10").removeClass("recortar");
1000
								$(".canvas").removeClass("recortar");
1001
								$(".b1").addClass("paso");
1002
								$(".titulo_pasos").html("LABEL_STEP_3");
1003
								if(texto!=""){
1004
									seis=true;
1005
									siete=true;
1006
								}
1007
								cinco=true;
1008
								dos=true;
1009
								cuatro=true;
1010
								actualizar();
6682 nelberth 1011
 
6888 nelberth 1012
							},editorNoticia(image));
6891 nelberth 1013
 
1014
 
1015
							selectorElementoName.trigger('change');
1016
						},selectorElementoEditor.html(nuevoHtmlImagen));
6888 nelberth 1017
					}
6891 nelberth 1018
 
6682 nelberth 1019
				}else{
1020
					setTimeout(function(){
1021
					    selectorElementoName.trigger('change');
1022
					},selectorElementoEditor.html(nuevoHtmlImagen));
1023
				}
1024
 
1025
		}
1026
 
1027
		$(window).on("scroll", function(){
1028
			console.log(scroll_altura)
1029
		if($(window).scrollTop()>scroll_altura){
1030
			$("#cuadro_noticias").addClass("fixed");
1031
		}else{
1032
			$("#cuadro_noticias").removeClass("fixed");
1033
		}
1034
	})
1035
 
1036
	$(document).on("dragover", "#imagen_noticia", function(e){
1037
		e.preventDefault();
1038
		e.stopPropagation();
1039
		$(this).css({"background":"rgba(0,0,0,.2)"})
1040
	})
11259 nelberth 1041
 
11260 nelberth 1042
	$(window).resize(function() {
11259 nelberth 1043
		anchoFondoOscuro = $(".articulo_noticia").width();
1044
		altoFondoOscuro = $(".editor_imagenes").height();
11260 nelberth 1045
		setTimeout(function(){
1046
			anchoFondoOscuro = $(".articulo_noticia").width();
1047
			altoFondoOscuro = $(".editor_imagenes").height();
1048
		},300)
11259 nelberth 1049
 
1050
	});
11260 nelberth 1051
 
6682 nelberth 1052
	$(document).on("drop", "#imagen_noticia", function(e){
1053
		e.preventDefault();
1054
		e.stopPropagation();
1055
		$(this).css("background", "none");
1056
		var archivo = e.originalEvent.dataTransfer.files;
1057
		var img=archivo[0];
1058
		if(img.type =="image/jpeg"||img.type =="image/png"){
1059
			$(".modificar").removeClass("animated");
1060
			var render = new FileReader();
1061
			render.readAsDataURL(img);
1062
			render.onload = function(e){
8354 nelberth 1063
				imagen2=new Image();
1064
				imagen2.src=e.target.result;
1065
 
1066
				$(imagen2).ready(function(e){
11030 nelberth 1067
					if(imagen2.width<320||imagen2.height<480){
8360 nelberth 1068
						$.fn.showError('LABEL_MINIMUM_IMAGE_SIZE');
8354 nelberth 1069
					}else{
1070
						$(".volver").css("display","block")
1071
						$(".a1").addClass("paso");
1072
						$(".titulo_pasos").html("LABEL_STEP_2");
1073
						editorNoticia(imagen2.src)
1074
					}
1075
				})
1076
			}
1077
		}else{
8360 nelberth 1078
			$.fn.showError('LABEL_SUPPORTED_FORMATS');
6682 nelberth 1079
		}
1080
	})
11030 nelberth 1081
	$(document).on("change", "#imagen_noticia_file", function(e){
1082
		file = $(this)[0].files[0];
1083
		e.preventDefault();
1084
		$(this).css("background", "none");
1085
		var archivo = file;
1086
		var img=file;
1087
		if(img.type =="image/jpeg"||img.type =="image/png"){
1088
			$(".modificar").removeClass("animated");
1089
			var render = new FileReader();
1090
			render.readAsDataURL(img);
1091
			render.onload = function(e){
1092
				imagen2=new Image();
1093
				imagen2.src=e.target.result;
1094
 
1095
				$(imagen2).ready(function(e){
1096
					if(imagen2.width<320||imagen2.height<480){
1097
						$.fn.showError('LABEL_MINIMUM_IMAGE_SIZE');
1098
					}else{
1099
						$(".volver").css("display","block")
1100
						$(".a1").addClass("paso");
1101
						$(".titulo_pasos").html("LABEL_STEP_2");
1102
						editorNoticia(imagen2.src)
1103
					}
1104
				})
1105
			}
1106
		}else{
1107
			$.fn.showError('LABEL_SUPPORTED_FORMATS');
1108
		}
1109
	})
6682 nelberth 1110
	$(document).on("dragover", "body", function(e){
1111
		e.preventDefault();
1112
		e.stopPropagation();
1113
	})
1114
	$(document).on("drop", "body", function(e){
1115
		e.preventDefault();
1116
		e.stopPropagation();
1117
	})
1118
 
1119
	var canvas='<div class="editorNoticia"><canvas id="editorNoticia">LABEL_NOT_SUPPORTED</canvas></div>';
1120
	$(document).on("mouseover", ".editorNoticia", function(){
12344 nelberth 1121
		const getScrollBarWidth = () => window.innerWidth - document.documentElement.getBoundingClientRect().width
1122
		let anchoScroll= getScrollBarWidth()+"px";
6682 nelberth 1123
		$("body").css({"overflow": "hidden"});
12344 nelberth 1124
		$(".cuadro_noticias, .fixed_noticia,.tituloEditor,.grid-padre,.subpanel").css("margin-right",anchoScroll )
1125
		$(".barra,.footer").css("padding-right",anchoScroll)
6682 nelberth 1126
 
12344 nelberth 1127
 
6682 nelberth 1128
 
1129
	})
1130
	$(document).on("mouseover", "#editorNoticia", function(){
1131
		if(recorte_listo){
1132
			ocho=true;
1133
		}
1134
	})
1135
	$(document).on("mouseout", "#editorNoticia", function(){
1136
		if(recorte_listo){
1137
			ocho=false;
1138
			actualizar2()
1139
		}
1140
	})
1141
	$(document).on("mouseout", ".editorNoticia",function(){
1142
		$("body").css({"overflow": "auto"})
1143
		$(".cuadro_noticias, .fixed_noticia,.tituloEditor,.grid-padre").css("margin-right", "0px")
1144
		$(".barra,.footer").css("padding-right","0px")
1145
 
1146
	})
1147
	$(document).on('mousewheel', ".editorNoticia",function(e){
1148
		var ruedita = e.originalEvent.wheelDelta
1149
		if(ruedita>0){
1150
			scale = scale+(scale/10);
1151
			$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1152
		}else{
1153
			scale = scale-(scale/10);
1154
			$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1155
		}
1156
		$("#editorNoticia").css({"transform": "scale("+scale+")"});
1157
	})
1158
	$(document).on("click", ".as", function(e){
1159
		e.preventDefault();
1160
		 scale = $(this).data("scale");
1161
		 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
1162
		 $("#editorNoticia").css({"transform": "scale("+scale+")"});
1163
 
1164
	})
1165
	$(document).on("click", ".ps", function(e){
1166
		e.preventDefault();
1167
		$(".cantidades_scale").slideToggle(200).css("display", "block");
1168
	})
1169
	$(document).on("click", "#cerrar_filter_modal, .icon_filter", function(e){
1170
		e.preventDefault();
1171
		if(recorte_listo){
1172
		$(".contenido_filter").slideToggle(200).css("display", "block");
1173
		}
1174
	})
1175
	$(document).on("click", "#cerrar_text_modal, .icon_text", function(e){
1176
		e.preventDefault();
1177
		if(recorte_listo){
1178
			$(".contenido_text").slideToggle(200).css("display", "block");
1179
		}
1180
	})
1181
 
1182
	$(document).on("click", "#cerrar_cut_modal, .icon_cut", function(e){
1183
		e.preventDefault();
1184
		if(cortar){
1185
			$(".contenido_cut").slideToggle(200).css("display", "block");
1186
		}
1187
 
1188
	})
1189
	$(document).on("click", "#menos_scale", function(e){
1190
		e.preventDefault();
1191
		scale = scale-(scale/10);
1192
		 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
1193
		 $("#editorNoticia").css({"transform": "scale("+scale+")"});
1194
	})
1195
 
1196
	$(document).on("click", "#mas_scale", function(e){
1197
		e.preventDefault();
1198
		scale = scale+(scale/10);
1199
		 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
1200
		 $("#editorNoticia").css({"transform": "scale("+scale+")"});
1201
	})
11045 nelberth 1202
	$(document).on('change', '#selectFiltro', function(e){
1203
 
1204
		data=$(this).val()
1205
		if(data=="normal"){
1206
			filter();
1207
		}else{
1208
			data=data.split(',');
1209
			if(data[2]=='gris'){
1210
				filtergris(data[0],data[1]);
1211
			}else{
1212
				filter(Number(data[0]),Number(data[1]),Number(data[2]),Number(data[3]),Number(data[4]),Number(data[5]));
1213
			}
1214
		}
6682 nelberth 1215
	})
1216
	var texto_listo=false,siete=false;
11251 nelberth 1217
	var texto;
6682 nelberth 1218
	$(document).on("keyup", "#texto_input", function(e){
1219
		e.preventDefault();
1220
		texto = $(this).val();
1221
		if(texto_actualizar){
1222
			siete=true;
1223
		}
1224
		if(texto!=""){
1225
			texto_actualizar=true;
1226
			actualizar2();
1227
		}else{
1228
			actualizar2();
1229
		}
1230
 
1231
	})
1232
	var color="#ffffff";
11041 nelberth 1233
	$(document).on("change input", "#color", function(){
6682 nelberth 1234
    	color=$(this).val();
1235
    	seis=true;
1236
    	actualizar2();
1237
    })
11040 nelberth 1238
	$(document).on("keypress", "#font-size, #texto_input", function(e){
1239
    	if(e.which == 13){
1240
      		return false;
1241
    	}
1242
  	});
6682 nelberth 1243
    var size=48;
1244
    $(document).on("keyup change", "#font-size", function(){
1245
    	size=$(this).val();
1246
    	size = parseInt(size);
1247
    	seis=true;
1248
    	siete=true;
1249
    	actualizar2();
1250
    })
1251
    var negritas=false, bold="";
1252
    $(document).on("click", "#negritas", function(e){
1253
    	e.preventDefault();
1254
    	if(!negritas){
1255
    		bold="bold";
1256
    		$(this).addClass("fa");
1257
    		seis=true;
1258
    		siete=true;
1259
    		actualizar2();
1260
    		negritas=true;
1261
    	}else{
1262
    		bold="";
1263
    		$(this).removeClass("fa");
1264
    		seis=true;
1265
    		siete=true;
1266
    		actualizar2();
1267
    		negritas=false;
1268
    	}
1269
    })
1270
    var italic=false, ita="";
1271
     $(document).on("click", "#italic", function(e){
1272
    	e.preventDefault();
1273
    	if(!italic){
1274
    		ita="italic";
1275
    		$(this).addClass("fa");
1276
    		seis=true;
1277
    		siete=true;
1278
    		actualizar2();
1279
    		italic=true;
1280
    	}else{
1281
    		ita="";
1282
    		$(this).removeClass("fa");
1283
    		seis=true;
1284
    		siete=true;
1285
    		actualizar2();
1286
    		italic=false;
1287
    	}
1288
    })
11039 nelberth 1289
	var fontfamily="Arial";
1290
     $(document).on("change", "#selectFuente", function(e){
6682 nelberth 1291
    	e.preventDefault();
11039 nelberth 1292
    	fontfamily= $(this).val();
6682 nelberth 1293
    	seis=true;
1294
    	siete=true;
1295
    	actualizar2();
1296
 
1297
    })
1298
     var shadow = true, nueve=true;
1299
     $(document).on("click","#shadow", function(e){
1300
     	e.preventDefault();
1301
     	if(shadow){
1302
     		$(this).removeClass("fa");
1303
     		seis=true;
1304
     		nueve=false;
1305
     		actualizar2();
1306
     		shadow=false;
1307
     	}else{
1308
     		$(this).addClass("fa");
1309
     		seis=true;
1310
     		nueve=true;
1311
     		actualizar2();
1312
     		shadow=true;
1313
     	}
1314
 
1315
     })
1316
     var rectangulo=false, diez=false, colorrect="#000000";
11042 nelberth 1317
	 $(document).on("click", "#rectangulo", function(e){
6682 nelberth 1318
     	e.preventDefault();
1319
     	if(!rectangulo){
1320
     		$(this).addClass("fa");
11042 nelberth 1321
			$('.color_fondo_cuadro').css('display','flex')
6682 nelberth 1322
     		diez=true;
1323
     		actualizar2();
1324
     		rectangulo=true;
1325
     	}else{
1326
     		$(this).removeClass("fa");
11042 nelberth 1327
			 $('.color_fondo_cuadro').css('display','none')
6682 nelberth 1328
     		diez=false;
1329
     		actualizar2();
1330
     		rectangulo=false;
1331
     	}
1332
 
1333
     })
1334
     var r=0,g=0,b=0;
11043 nelberth 1335
	 $(document).on("change input", "#colorrect", function(){
6682 nelberth 1336
    	colorrect=$(this).val();
11043 nelberth 1337
    	r=parseInt(colorrect.slice(1,3),16);
1338
    	g=parseInt(colorrect.slice(3,5),16);
1339
    	b=parseInt(colorrect.slice(5,7),16);
6682 nelberth 1340
    	seis=true;
1341
    	actualizar2();
1342
    })
1343
    var a=1;
1344
 
11044 nelberth 1345
	$(document).on("mousemove change ", "#opacidad", function(){
6682 nelberth 1346
    	a=$(this).val();
1347
    	a=a/100;
1348
    	seis=true;
1349
    	actualizar2();
1350
    })
1351
	var imaNoti = new Image();
1352
	function filter(brillo=1, contraste=1, rojo=1, verde=1, azul=1, valor=1){
1353
		cuatro=false;
1354
		restaurar(brillo, contraste);
1355
		datos=imagenOriginal.data;
1356
		if(valor==2){
1357
			for (var i =  0; i <datos.length; i+=4) {
1358
				datos[i]=datos[i]+rojo;
1359
				datos[i+1]=datos[i+1]+verde;
1360
				datos[i+2]=datos[i+2]+azul;
1361
			}
1362
		}else{
1363
			for (var i =  0; i <datos.length; i+=4) {
1364
				datos[i]=datos[i]*rojo;
1365
				datos[i+1]=datos[i+1]*verde;
1366
				datos[i+2]=datos[i+2]*azul
1367
			}
1368
		}
1369
		editor.putImageData(imagenOriginal,0,0)
1370
		var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
1371
	    imaNoti.src = imagenNoticia;
1372
		actualizar2();
1373
	}
1374
	function filtergris(brillo=1, contraste=1){
1375
		cuatro=false;
1376
		restaurar(brillo, contraste);
1377
		datos=imagenOriginal.data;
1378
		var auxiliar;
1379
		for (var i =  0; i <datos.length; i+=4) {
8356 nelberth 1380
			auxiliar = 0.34 * datos[i] + 0.5 *datos[i+1] + 0.1/6 * datos[i+2];
6682 nelberth 1381
			datos[i]=auxiliar;
1382
			datos[i+1]=auxiliar;
1383
			datos[i+2]=auxiliar;
1384
		}
1385
 
1386
		editor.putImageData(imagenOriginal,0,0)
1387
		var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
1388
	    imaNoti.src = imagenNoticia;
1389
		actualizar2();
1390
	}
1391
	function restaurar(brillo = 1, contraste=1){
1392
		editor.filter = "none"
1393
		editor.filter = 'contrast('+contraste+') brightness('+brillo+') saturate(1) sepia(0)';
1394
		editor.fillStyle="rgba(255,255,255,1)"
1395
		editor.fillRect(0,0,ancho,alto);
1396
		editor.fillStyle=""+color+"";
1397
		var pxf=0,pyf=0;
1398
			if(xf>=(yf/recorte)){
1399
				pxf=xf/ancho;
1400
				pyf=yf/pxf;
1401
				py=(alto/2)-(pyf/2);
1402
				editor.drawImage(imagen,x,y,xf,yf,0,py,ancho,pyf);
1403
			}else{
1404
				pyf=yf/alto;
1405
				pxf=xf/pyf;
1406
				px=(ancho/2)-(pxf/2);
1407
				editor.drawImage(imagen,x,y,xf,yf,px,0,pxf,alto);
1408
			}
1409
		imagenOriginal = editor.getImageData(0,0,ancho,alto)
1410
	}
1411
	var ocho=false;
1412
	function actualizar2(){
1413
		if(recorte_listo){
1414
		if(cuatro){
1415
			imagenOriginal = editor.getImageData(0,0,ancho,alto)
1416
			var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
1417
	    	imaNoti.src = imagenNoticia;
1418
	    	cuatro=false;
1419
		}
1420
		editor.filter = "none"
1421
		$(imaNoti).ready(function(e){
6926 nelberth 1422
			noticia.drawImage(imaNoti,0,0,pw,ph);
6682 nelberth 1423
			editor.drawImage(imaNoti,0,0,ancho,alto)
1424
			if(texto_actualizar){
1425
				if(texto!=""){
1426
					if(seis){
1427
						ancho_imaNoti = imaNoti.width;
1428
 
6926 nelberth 1429
						scale_noticia = -(((ancho_imaNoti-pw)/ancho_imaNoti)-1);
6682 nelberth 1430
						editor.fillStyle=""+color+"";
1431
						editor.strokeStyle="rgb(255,255,255)";
1432
						if(nueve){
1433
							editor.shadowColor="rgba(0,0,0,.5)";
1434
							editor.shadowOffsetX=6;
1435
							editor.shadowOffsetY=6;
1436
							editor.shadowBlur=6;
1437
							noticia.shadowColor="rgba(0,0,0,.5)";
1438
							noticia.shadowOffsetX=6*scale_noticia;
1439
							noticia.shadowOffsetY=6*scale_noticia;
1440
							noticia.shadowBlur=6*scale_noticia;
1441
						}else{
1442
							editor.shadowColor="rgba(0,0,0,0)";
1443
							noticia.shadowColor="rgba(0,0,0,0)";
1444
						}
1445
						editor.font=""+ita+" "+bold+" "+size+"px "+fontfamily+"";
1446
						editor.textAlign="start";
1447
						editor.textBaseline="top";
1448
 
1449
						var sizeNoticia = size*scale_noticia;
1450
						noticia.fillStyle=""+color+"";
1451
						noticia.font=""+ita+" "+bold+" "+sizeNoticia+"px "+fontfamily+"";
1452
						noticia.textAlign="start";
1453
						noticia.textBaseline="top";
1454
						seis=false;
1455
					}
1456
					if(siete){
1457
						dimencionesTexto = editor.measureText(texto);
1458
						txf=dimencionesTexto.width+20;
1459
						tyf= (20+size);
1460
						siete=false;
1461
					}
1462
					if(cinco){
1463
						dimencionesTexto = editor.measureText(texto);
1464
						if(xf>=(yf/recorte)){
1465
							tx=(xf/2)-(dimencionesTexto.width/2);
1466
							ty=(xf*recorte/2)-(size/2);
1467
						}else{
1468
							tx=(yf/recorte/2)-(dimencionesTexto.width/2);
1469
							ty=(yf/2)-(size/2);
1470
						}
1471
 
1472
						txf=dimencionesTexto.width+20;
1473
						tyf= size+20;
1474
						cinco=false;
1475
					}
1476
					if(diez){
1477
						editor.fillStyle="rgba("+r+","+g+","+b+","+a+")";
1478
						noticia.fillStyle="rgba("+r+","+g+","+b+","+a+")";
1479
						editor.fillRect(tx-10,ty-10,txf,tyf);
1480
						noticia.fillRect(((tx-10)*scale_noticia),((ty-10)*scale_noticia),txf*scale_noticia,tyf*scale_noticia);
1481
						editor.fillStyle=""+color+"";
1482
						noticia.fillStyle=""+color+"";
1483
 
1484
					}
1485
					editor.fillText(texto,tx,ty);
1486
					noticia.fillText(texto,(tx*scale_noticia),ty*scale_noticia);
1487
					if(ocho){
1488
						editor.strokeRect(tx-10,ty-10,txf,tyf)
1489
						editor.arc(tx+txf,ty+tyf,10,0,Math.PI*2,false);
1490
						editor.fill();
1491
						editor.beginPath();
1492
					}
1493
					texto_listo=true;
1494
				}
1495
			}
1496
		})
1497
 
1498
	}
1499
	}
1500
	function actualizar(){
6962 nelberth 1501
 
6961 nelberth 1502
			$(imagen).ready(function(e){
1503
 
6682 nelberth 1504
				if(uno){
6962 nelberth 1505
					elemento2.height=ph;
6964 nelberth 1506
					elemento2.width=pw;
6682 nelberth 1507
					ancho=imagen.width, alto = imagen.height;
1508
					elemento.width = ancho;
1509
					elemento.height = alto;
6956 nelberth 1510
 
6682 nelberth 1511
					$(".scale").css("display","flex");
1512
					if(ancho<=alto){
1513
					 scale = -(((alto-450)/alto)-1);
8357 nelberth 1514
 
1515
 
6682 nelberth 1516
					}else{
1517
					 scale = -(((ancho-500)/ancho)-1);
8357 nelberth 1518
 
6682 nelberth 1519
					}
11033 nelberth 1520
					scale=scale*0.80;
8579 nelberth 1521
					if(edit){
1522
						if((ancho*recorte)<=alto){
1523
							xf=ancho*.70;
1524
							yf=xf*recorte;
1525
						}else{
1526
							yf=alto*.70;
1527
							xf=yf/recorte;
1528
						}
1529
					}
8357 nelberth 1530
					cuadro_dimencion=Math.round(12/scale);
1531
 
1532
					if(xf<50||yf<50){
1533
						xf=50;
1534
						yf=xf*recorte;
1535
					}
1536
					mitadX=ancho/2;
1537
					mitadY=alto/2;
1538
					x=mitadX-xf/2;
1539
					y=mitadY-yf/2;
1540
 
6682 nelberth 1541
					$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1542
					$("#ancho").html(ancho+"px");
1543
					$("#alto").html(alto+"px");
1544
					uno=false;
1545
				}
1546
				if(dos){
1547
 
1548
					if(xf>=(yf/recorte)){
1549
						alto=xf*recorte;
1550
						ancho=xf;
1551
					}else{
1552
						ancho=yf/recorte;
1553
						alto=yf;
1554
 
1555
					}
1556
					elemento.width = ancho;
1557
					elemento.height = alto;
6963 nelberth 1558
					elemento2.height=ph;
1559
					elemento2.width=pw;
6682 nelberth 1560
					if(xf<=yf){
1561
					 scale = -(((yf-450)/yf)-1);
1562
 
1563
					}else{
1564
					 scale = -(((xf-500)/xf)-1);
1565
					}
1566
 
1567
					$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1568
					$("#ancho").html(Math.round(xf)+"px");
1569
					$("#alto").html(Math.round(yf)+"px");
1570
					dos=false;
1571
				}
1572
 
1573
					var pxf=0,pyf=0;
1574
					noticia.fillStyle="rgba(255,255,255,1)"
6926 nelberth 1575
					noticia.fillRect(0,0,pw,ph);
6682 nelberth 1576
				if(xf>=(yf/recorte)){
6926 nelberth 1577
					pxf=xf/pw;
6682 nelberth 1578
					pyf=yf/pxf;
6926 nelberth 1579
					py=(ph/2)-(pyf/2);
1580
					noticia.drawImage(imagen,x,y,xf,yf,0,py,pw,pyf);
6682 nelberth 1581
				}else{
6926 nelberth 1582
					pyf=yf/ph;
6682 nelberth 1583
					pxf=xf/pyf;
6926 nelberth 1584
					px=(pw/2)-(pxf/2);
1585
					noticia.drawImage(imagen,x,y,xf,yf,px,0,pxf,ph);
6682 nelberth 1586
				}
1587
 
1588
				$("#editorNoticia").css({"transform": "scale("+scale+")"});
1589
				if(!recorte_listo){
1590
					editor.drawImage(imagen,0,0,ancho,alto);
1591
					editor.fillStyle="rgba(0,0,0,.2)"
1592
					editor.fillRect(0,0,ancho,alto);
8358 nelberth 1593
					editor.fillStyle="rgba(255,255,255,.2)"
6682 nelberth 1594
					editor.fillRect(x,y,xf,yf);
8358 nelberth 1595
					editor.fillStyle="rgba(255,255,255,0.8)"
8356 nelberth 1596
					editor.fillRect(x,y,cuadro_dimencion,cuadro_dimencion);
1597
					editor.fillRect((x+xf)-cuadro_dimencion,y,cuadro_dimencion,cuadro_dimencion);
1598
					editor.fillRect(x,y+yf-cuadro_dimencion,cuadro_dimencion,cuadro_dimencion);
1599
					editor.fillRect(x+xf-cuadro_dimencion,yf+y-cuadro_dimencion,cuadro_dimencion,cuadro_dimencion);
6682 nelberth 1600
					esta=true;
1601
				}else{
1602
					var pxf=0,pyf=0;
1603
 
1604
					editor.fillStyle="rgba(255,255,255,1)"
1605
					editor.fillRect(0,0,ancho,alto);
1606
					if(xf>=(yf/recorte)){
1607
						pxf=xf/ancho;
1608
						pyf=yf/pxf;
1609
						py=(alto/2)-(pyf/2);
1610
						editor.drawImage(imagen,x,y,xf,yf,0,py,ancho,pyf);
1611
					}else{
1612
						pyf=yf/alto;
1613
						pxf=xf/pyf;
1614
						px=(ancho/2)-(pxf/2);
1615
						editor.drawImage(imagen,x,y,xf,yf,px,0,pxf,alto);
1616
				}
1617
 
1618
				}
1619
			})
1620
		}
6966 nelberth 1621
	var imagenOriginal
6956 nelberth 1622
	var x,y,xf=pw,yf =ph, elemento,elemento2,editor,centro, total,scale,dimencionesTexto,ancho_imaNoti,
6682 nelberth 1623
	recorte_listo=false,alto,ancho,tx,ty,txf,tyf,cuatro=true,texto_actualizar=false,cinco=true,seis=true,cuatro;
6970 nelberth 1624
	var  mitadY,mitadX, uno=true,dos=false, recorte=ph/pw, imagen_noticias, scale_noticia, tres=true,rotar=false, cortar=false;;
8356 nelberth 1625
	var translateX, cuadro_dimencion;
6682 nelberth 1626
 
1627
	$(document).on("click", ".recortar10", function(e){
1628
 
1629
		e.preventDefault();
1630
		recorte_listo=false;
1631
		uno=true;
7000 nelberth 1632
		$("#boton_recortar").addClass("recortar").text("LABEL_CUT").removeClass("info_noticia");
1633
		$("#boton_recortar3").addClass("recortar").text("LABEL_CUT").removeClass("info_noticia3");
6682 nelberth 1634
		$(".contenido_text").css("display", "none");
1635
		$(".contenido_filter").css("display", "none");
1636
		$(".recortar10").addClass("recortar");
1637
		$(".canvas").addClass("recortar")
1638
		$(".oa").removeClass("oa");
1639
		$("#normal").addClass("oa");
1640
		$(".b1").removeClass("paso");
1641
		$(".titulo_pasos").html("LABEL_STEP_2");
1642
		window.clearInterval(actualizar2);
1643
		actualizar();
1644
 
1645
	})
1646
 
1647
 
1648
	blockCelda=true;
1649
	$(document).on("click", "#blockCelda", function(e){
1650
		e.preventDefault();
1651
		if(blockCelda){
1652
			$(this).html('<span class="fa fa-unlock"></span>')
1653
 
1654
			blockCelda=false;
1655
		}else{
1656
			$(this).html('<span class="fa fa-lock"></span>')
1657
			blockCelda=true;
1658
		}
1659
		t4=true;
1660
 
1661
	})
1662
	var imagen
1663
	function editorNoticia(img){
1664
		 cortar=true;
1665
		imagen= new Image();
1666
		$(".canvas").html(canvas);
1667
		elemento = document.getElementById("editorNoticia");
1668
		editor = elemento.getContext("2d");
1669
		elemento2 = document.getElementById("imagen_noticias");
1670
		noticia = elemento2.getContext("2d");
1671
 
1672
		$(document).on("click", ".boton_marino.recortar",function(e){
1673
			e.preventDefault();
1674
			recorte_listo=true;
1675
			$(".fondo_oscuro").css("display","none");
6863 nelberth 1676
			if(fileToggle){
15026 stevensc 1677
				$("#boton_recortar").removeClass("recortar").text("LABEL_ATTACH_IMAGE").addClass("info_noticia");
1678
			}else{
15025 stevensc 1679
				$("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
6863 nelberth 1680
			}
6682 nelberth 1681
			$(".recortar10").removeClass("recortar");
1682
			$(".canvas").removeClass("recortar");
1683
			$(".b1").addClass("paso");
1684
			$(".titulo_pasos").html("LABEL_STEP_3");
1685
			if(texto!=""){
1686
				seis=true;
1687
				siete=true;
1688
			}
1689
			cinco=true;
1690
			dos=true;
1691
			cuatro=true;
11252 nelberth 1692
			setTimeout(() => {
1693
				actualizar2();
1694
			}, actualizar());
1695
 
6682 nelberth 1696
		})
1697
 
1698
		var cli = false, t1= false, t2=false,t3=false,t4=false,tcli=false;
1699
		var mouse =[];
1700
 
1701
 
1702
		function raton(elemento, e){
1703
			return {
1704
				x:((e.pageX - elemento.offsetLeft - ((ancho/2)-((ancho*scale)/2)))/scale),
1705
				y:((e.pageY - elemento.offsetTop - ((alto/2)-((alto*scale)/2)))/scale)
1706
			}
1707
		}
1708
 
1709
		imagen.src=img;
1710
		$(".recortar10").addClass("recortar");
1711
		$("#boton_recortar").removeClass("boton_normal").addClass("recortar boton_marino").text("LABEL_CUT")
1712
		actualizar();
1713
 
1714
		$(elemento).mousemove(function(e){
1715
			mouse = raton(this, e);
1716
			//console.log("raton x: "+mouse.x+ " raton Y: " +mouse.y+ " tx: "+tx+" ty: "+ty+" txf:"+(txf+tx)+" tyf:"+(tyf+ty) )
1717
			if(!recorte_listo){
8356 nelberth 1718
				if(x<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+yf)>mouse.y){
1719
					if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y && (y+yf)>mouse.y){
1720
			 			$(elemento).css("cursor","nw-resize");
1721
			 		}else if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
1722
			 			$(elemento).css("cursor","ne-resize");
1723
			 		}else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
1724
			 			$(elemento).css("cursor","se-resize");
1725
			 		}else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y &&(y+yf)>mouse.y){
1726
			 			$(elemento).css("cursor","sw-resize");
1727
			 		}else{
1728
						$(elemento).css("cursor","move");
1729
					}
6682 nelberth 1730
			 	}else{
1731
			 		$(elemento).css("cursor","default");
1732
			 	}
1733
			}else if(texto_listo){
1734
				if(tx-10<mouse.x && tx-10+txf>mouse.x && ty-10<mouse.y && ty-10+tyf>mouse.y){
1735
			 		$(elemento).css("cursor","move");
1736
			 	}else if((txf+tx-10)<mouse.x &&(txf+tx-10+20)>mouse.x && (ty-10+tyf)<mouse.y && (ty-10+tyf+20)>mouse.y){
1737
			 		$(elemento).css("cursor","pointer");
1738
			 	}else{
1739
			 		$(elemento).css("cursor","default");
1740
			 	}
1741
			}
1742
			else{
1743
				$(elemento).css("cursor","default");
1744
			}
1745
		})
1746
		$(elemento).mousedown(function(e){
1747
			mouse = raton(this, e);
1748
			if(!recorte_listo){
8356 nelberth 1749
				if(x<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+yf)>mouse.y){
1750
 
1751
					 if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y && (y+yf)>mouse.y){
1752
						 t4 = true;
1753
					 }else if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
1754
						 t3 = true;
1755
					 }else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
1756
						 t1 = true;
1757
					 }else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y &&(y+yf)>mouse.y){
1758
						 t2 = true;
1759
					 }else{
1760
						 cli = true;
1761
					 }
1762
				  }
6682 nelberth 1763
			}else if(texto_listo){
1764
				if(tx-10<mouse.x && tx-10+txf>mouse.x && ty-10<mouse.y && ty-10+tyf>mouse.y){
1765
			 		tcli=true;
1766
			 	}else if((txf+tx-10)<mouse.x &&(txf+tx-10+20)>mouse.x && (ty-10+tyf)<mouse.y && (ty-10+tyf+20)>mouse.y){
1767
			 		rotar=true;
1768
			 	}
1769
			}
1770
 
1771
		 })
1772
 
11033 nelberth 1773
		 $('.editorNoticia').mousemove(function(e){
6682 nelberth 1774
		 	mouse = raton(this, e);
1775
		 	if(!recorte_listo){
1776
			 	if(cli){
1777
			 		if((mouse.y-(yf/2))>=0&&(mouse.y+(yf/2))<=alto){
1778
				 		y = (mouse.y-(yf/2));
1779
			 		}else{
1780
			 			if((mouse.y-(yf/2))<0){
1781
			 				y=0;
1782
			 			}
1783
			 			if((mouse.y+(yf/2))>alto){
1784
			 				y=alto-yf;
1785
			 			}
1786
			 		}
1787
			 		if((mouse.x-(xf/2))>=0&&(mouse.x+(xf/2))<=ancho){
1788
			 			x = (mouse.x-(xf/2));
1789
			 		}else{
1790
			 			if((mouse.x-(xf/2))<0){
1791
			 				x=0;
1792
			 			}
1793
			 			if((mouse.x+(xf/2))>ancho){
1794
			 				x=(ancho)-xf;
1795
			 			}
1796
			 		}
1797
			 	}
11038 nelberth 1798
				 if(blockCelda){
6682 nelberth 1799
			 	if(t4){
11032 nelberth 1800
					cal1=mouse.y-y;
1801
			 		cal2=cal1/recorte;
1802
					cal3=x+cal2;
1803
					if(cal2>50){
1804
						if(cal3<=ancho&&mouse.y<=alto){
1805
							yf=cal1;
1806
				 			xf=cal2;
1807
						}else if(cal3<=ancho&&mouse.y>alto){
1808
							yf=alto-y;
1809
							xf=yf/recorte
1810
						}else if(cal3>=ancho&&mouse.y<=alto){
1811
							xf=ancho-x;
1812
							yf=xf*recorte;
6682 nelberth 1813
						}
11032 nelberth 1814
				 	}
6682 nelberth 1815
			 	}
1816
			 	if(t3){
11032 nelberth 1817
					cal1=yf+(y-mouse.y);
1818
			 		cal2=cal1/recorte;
1819
					cal3=x+cal2;
1820
					if(cal2>50){
1821
						if(cal3<=ancho&&mouse.y>=0){
1822
							yf=cal1;
1823
				 			xf=cal2;
1824
							y=mouse.y;
1825
						}else if(cal3<=ancho&&mouse.y<0){
1826
							yf=yf+y;
1827
							xf=yf/recorte
1828
							y=0;
11038 nelberth 1829
						}else if(cal3>=ancho&&mouse.y>=0){
11032 nelberth 1830
							xf=ancho-x;
1831
							y=y+(yf-xf*recorte);
1832
							yf=xf*recorte;
1833
						}
1834
 
1835
				 	}
1836
 
6682 nelberth 1837
			 	}
1838
			 	if(t2){
11032 nelberth 1839
 
1840
					cal1=mouse.y-y;
11245 nelberth 1841
					cal2=cal1/recorte;
11032 nelberth 1842
					cal3=x+(yf-cal1)/recorte;cal2;
1843
					if(cal2>50){
1844
						if(cal3>=0&&mouse.y<=alto){
1845
							x=cal3;
1846
							yf=cal1;
11245 nelberth 1847
							xf=cal2;
1848
						}else if(cal3>0&&mouse.y>alto){
11032 nelberth 1849
							yf=alto-y;
1850
							x=x+(xf-yf/recorte);
1851
							xf=yf/recorte
11038 nelberth 1852
						}else if(cal3<0&&mouse.y<=alto){
11032 nelberth 1853
							xf=xf+x;
1854
							yf=xf*recorte;
1855
							x=0;
1856
						}
11245 nelberth 1857
					}
1858
 
1859
				}
1860
				if(t1){
11032 nelberth 1861
					cal0=y-mouse.y;
1862
					cal1=yf+cal0;
11245 nelberth 1863
					cal2=cal1/recorte;
11032 nelberth 1864
					cal3=x-cal0/recorte;
1865
					if(cal2>50){
1866
						if(cal3>=0&&mouse.y>=0){
1867
							yf=cal1;
11245 nelberth 1868
							xf=cal2;
1869
							x=cal3;
1870
							y=mouse.y;
1871
						}else if(cal3>0&&mouse.y<0){
11032 nelberth 1872
							yf=yf+y;
1873
							x=x+(xf-yf/recorte);
1874
							xf=yf/recorte
1875
							y=0;
11038 nelberth 1876
						}else if(cal3<0&&mouse.y>=0){
11032 nelberth 1877
							xf=xf+x;
1878
							y=y+(yf-xf*recorte);
1879
							yf=xf*recorte;
1880
							x=0;
1881
						}
11245 nelberth 1882
					}
1883
 
11032 nelberth 1884
				}
6682 nelberth 1885
				}else{
11032 nelberth 1886
				if(t4){
1887
 
1888
					cal1=mouse.y-y;
1889
					cal2=mouse.x-x;
1890
					if(cal1>50){
1891
						yf=mouse.y<=alto?cal1:alto-y;
1892
				 	}
1893
					if(cal2>50){
1894
						xf=mouse.x<=ancho?cal2:ancho-x;
1895
					}
6682 nelberth 1896
			 	}
11032 nelberth 1897
 
6682 nelberth 1898
			 	if(t3){
11032 nelberth 1899
					cal1=yf-(mouse.y-y);
1900
					cal2=mouse.x-x;
1901
					if(cal1>50){
1902
 
1903
						if(mouse.y>=0){
1904
							yf=cal1;
1905
							y=mouse.y;
1906
						}else{
1907
							yf=yf+y;
6682 nelberth 1908
							y=0;
1909
						}
11032 nelberth 1910
				 	}
1911
					if(cal2>50){
1912
						xf=mouse.x<=ancho?cal2:ancho-x;
1913
					}
6682 nelberth 1914
			 	}
1915
				/* Izquierda abajo */
1916
			 	if(t2){
11032 nelberth 1917
					cal1=mouse.y-y;
1918
					cal2=xf-(mouse.x-x);
1919
					if(cal1>50){
1920
						yf=yf=mouse.y<=alto?cal1:alto-y;
1921
					}
1922
					if(cal2>50){
1923
						if(mouse.x>=0){
1924
							xf=cal2;
1925
							x=mouse.x;
1926
						}else{
1927
							xf=xf+x;
1928
							x=0;
1929
						}
1930
					}
6682 nelberth 1931
			 	}
1932
				/* izquierda arriba */
1933
			 	if(t1){
11032 nelberth 1934
 
1935
					cal1=yf-(mouse.y-y);
1936
					cal2=xf-(mouse.x-x);
1937
					if(cal1>50){
1938
 
1939
						if(mouse.y>=0){
1940
							yf=cal1;
1941
							y=mouse.y;
1942
						}else{
1943
							yf=yf+y;
6682 nelberth 1944
							y=0;
1945
						}
11032 nelberth 1946
				 	}
1947
					if(cal2>50){
1948
						if(mouse.x>=0){
1949
							xf=cal2;
1950
							x=mouse.x;
1951
						}else{
1952
							xf=xf+x;
1953
							x=0;
1954
						}
1955
					}
1956
 
6682 nelberth 1957
			 	}
11032 nelberth 1958
				}
6682 nelberth 1959
 
1960
		 	actualizar();
1961
		 	}else if(texto_listo){
1962
		 		if(tcli){
1963
		 			tx=mouse.x-(txf/2)
1964
		 			ty=mouse.y-(tyf/2)
1965
		 		}else if(rotar){
1966
 
1967
		 		}
1968
 
1969
		 		actualizar2();
1970
		 	}
1971
		 })
11034 nelberth 1972
		 $('body').mouseup(function(e){
6682 nelberth 1973
		 	if(!recorte_listo){
1974
			 	cli=false;
1975
			 	t1=false;
1976
			 	t2=false;
1977
			 	t3=false;
1978
			 	t4=false;
1979
		 	}else if (texto_listo) {
1980
		 		tcli=false;
1981
		 	}
1982
		 })
1983
 
1984
 
1985
	}
1986
	/* Titulo */
1987
 
1988
var titulo_noticia, censor_titulo = true, numero_titulo=0;
1989
	$(document).on("keyup change", "#name", function(e){
1990
	console.log(numero_titulo)
1991
	titulo_noticia = $(this).val();
1992
	titulo_elemento= $(".titulo_topico");
1993
	if(titulo_noticia!=""){
1994
		if(censor_titulo){
1995
			titulo_elemento.html(titulo_noticia);
1996
			if(titulo_elemento.height()>38){
1997
				var titulo_noticia2 = "";
1998
				for(var i =0; i <titulo_noticia.length;i++){
1999
					titulo_noticia2 = titulo_noticia2 + titulo_noticia.split("")[i];
2000
					titulo_elemento.html(titulo_noticia2);
2001
					if(titulo_elemento.height()>38){
2002
						titulo_noticia2 = titulo_noticia2.slice(0,-5) + "...";
2003
						titulo_elemento.html(titulo_noticia2);
2004
						numero_titulo = titulo_noticia2.length;
2005
						censor_titulo=false;
2006
						break;
2007
					}
2008
 
2009
				}
2010
			}else{
2011
				numero_titulo=0;
2012
			}
2013
		}else{
2014
			if(numero_titulo+1>=titulo_noticia.length){
2015
				titulo_elemento.html(titulo_noticia);
2016
				censor_titulo=true;
2017
			}
2018
		}
2019
	}else{
2020
		titulo_elemento.html("LABEL_TITLE");
2021
		censor_titulo = true;
2022
	}
2023
})
2024
 
1 www 2025
});
2026
JS;
2027
$this->inlineScript()->captureEnd();
2028
?>
2029
 
15139 stevensc 2030
 
2031
 
1 www 2032
<!-- Content Header (Page header) -->
2033
<section class="content-header">
2034
	<div class="container-fluid">
15139 stevensc 2035
		<div class="row mb-2">
2036
			<div class="col-sm-12">
2037
				<h1>LABEL_CAPSULES</h1>
1 www 2038
			</div>
2039
		</div>
2040
	</div><!-- /.container-fluid -->
2041
</section>
2042
 
6704 nelberth 2043
<section class="content" id="content1">
1 www 2044
	<div class="container-fluid">
15139 stevensc 2045
		<div class="row">
2046
			<div class="col-12">
2047
				<div class="card">
1 www 2048
					<div class="card-header">
15139 stevensc 2049
						<?php
2050
						$form = $this->form;
2051
						$form->setAttributes([
2052
							'name'    => 'form-filter',
2053
							'id'      => 'form-filter',
2054
						]);
2055
 
2056
						$form->prepare();
2057
						echo $this->form()->openTag($form);
2058
						?>
2059
						<div class="form-group">
2060
							<?php
2061
							$element = $form->get('topic_uuid');
2062
 
2063
							$element->setAttributes(['class' => 'form-control']);
2064
							$element->setLabel('LABEL_TOPIC');
2065
							echo $this->formLabel($element);
2066
							echo $this->formSelect($element);
2067
							?>
2068
						</div>
1 www 2069
						<?php echo $this->form()->closeTag($form); ?>
15139 stevensc 2070
					</div>
1 www 2071
					<div class="card-body">
15139 stevensc 2072
						<table id="gridTable" class="table   table-hover">
2073
							<thead>
2074
								<tr>
2075
									<th>LABEL_NAME</th>
2076
									<th>LABEL_DETAILS</th>
2077
									<th>LABEL_IMAGES</th>
2078
									<th>LABEL_ACTIONS</th>
2079
								</tr>
2080
							</thead>
2081
							<tbody>
2082
							</tbody>
2083
						</table>
2084
					</div>
2085
					<div class="card-footer clearfix">
2086
						<div style="float:right;">
2087
							<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
2088
							<?php if ($allowAdd) : ?>
2089
								<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
1 www 2090
							<?php endif; ?>
2091
						</div>
15139 stevensc 2092
					</div>
2093
				</div>
2094
			</div>
2095
		</div>
2096
	</div>
2097
</section>
1 www 2098
 
2099
 
2100
<!-- The Modal -->
6694 nelberth 2101
<div id="modalCapsuleAdd" style='display:none'>
1 www 2102
 
6694 nelberth 2103
 
15139 stevensc 2104
	<!-- Modal Header -->
1 www 2105
 
15139 stevensc 2106
	<div class="d-flex justify-content-center tituloEditor">
2107
		<h4>LABEL_ADD_CAPSULE</h4>
6701 nelberth 2108
 
15139 stevensc 2109
	</div>
2110
	<!-- Modal body -->
2111
	<div class="grid-padre">
2112
		<?php
2113
		$form = $this->formAdd;
2114
		$form->setAttributes([
2115
			'method'  => 'post',
2116
			'action'  => '',
2117
			'name'    => 'form-capsule-add',
2118
			'id'      => 'form-capsule-add',
2119
		]);
1 www 2120
 
15139 stevensc 2121
		$form->prepare();
2122
		echo $this->form()->openTag($form);
2123
		?>
2124
		<div class="form-group grid-1-2">
2125
			<?php
2126
			$element = $form->get('name');
1 www 2127
 
15139 stevensc 2128
			$element->setAttributes(['class' => 'form-control']);
2129
			$element->setOptions(['label' => 'LABEL_NAME']);
2130
			echo $this->formLabel($element);
2131
			echo $this->formText($element);
2132
			?>
2133
		</div>
2134
		<div class="form-group grid-1-2">
2135
			<?php
2136
			$element = $form->get('description');
2137
			$element->setAttributes(['id' => 'description_add', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
2138
			$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
2139
			echo $this->formLabel($element);
2140
			echo $this->formTextArea($element);
2141
			?>
2142
		</div>
2143
		<div class="form-group grid-1-2">
2144
			<?php
2145
			$element = $form->get('order');
2146
			$element->setAttributes(['class' => 'form-control']);
2147
			$element->setOptions(['label' => 'LABEL_ORDER']);
2148
			echo $this->formLabel($element);
2149
			echo $this->formText($element);
2150
			?>
2151
		</div>
1 www 2152
 
15139 stevensc 2153
		<div class="form-group grid-1-2">
2154
			<?php
2155
			$element = $form->get('status');
2156
			$element->setAttributes(['class' => 'form-control']);
2157
			$element->setOptions(['label' => 'LABEL_STATUS']);
2158
			echo $this->formLabel($element);
2159
			echo $this->formSelect($element);
2160
			?>
2161
		</div>
2162
		<div class="form-group grid-1-2">
2163
			<?php
2164
			$element = $form->get('privacy');
2165
			$element->setAttributes(['class' => 'form-control']);
2166
			$element->setOptions(['label' => 'LABEL_PRIVACY']);
2167
			echo $this->formLabel($element);
2168
			echo $this->formSelect($element);
2169
			?>
2170
		</div>
2171
		<div class="form-group grid-1-2">
2172
			<?php
2173
			$element = $form->get('type');
2174
			$element->setAttributes(['class' => 'form-control']);
2175
			$element->setOptions(['label' => 'LABEL_TYPE']);
2176
			echo $this->formLabel($element);
2177
			echo $this->formSelect($element);
2178
			?>
2179
		</div>
2180
		<div class="form-group grid-1-2" id="form-row-cost">
2181
			<?php
2182
			$element = $form->get('cost');
2183
			$element->setAttributes(['class' => 'form-control']);
2184
			$element->setOptions(['label' => 'LABEL_COST']);
2185
			echo $this->formLabel($element);
2186
			echo $this->formText($element);
2187
			?>
2188
		</div>
1 www 2189
 
15139 stevensc 2190
		<?php
2191
		$element = $form->get('marketplace');
2192
		$element->setAttributes(['class' => 'marketplace']);
2193
		echo $this->formHidden($element);
2194
		?>
2195
		<?php
2196
		$element = $form->get('file');
2197
		$element->setAttributes(['class' => 'file']);
2198
		echo $this->formHidden($element);
2199
		?>
2200
		<div class="form-group grid-1-2 ">
2201
			<div class="imagen-contaner">
2202
				<label for="marketplaceImg">LABEL_IMAGE_MARKETPLACE</label>
2203
				<img class='marketplaceImg' src='' class="img img-responsive" style="width: 100px; height: auto"></img>
2204
			</div>
2205
		</div>
2206
		<h5 style="text-align:center " class="form-group grid-1-2" id='titleTypeImage'>LABEL_IMAGE_MARKETPLACE</h5>
2207
		<div class="contenido form-group " id="contenido"></div>
2208
 
2209
		<?php echo $this->form()->closeTag($form); ?>
2210
	</div>
2211
 
2212
 
2213
 
2214
</div>
2215
 
2216
 
1 www 2217
<!-- The Modal -->
15139 stevensc 2218
<div id="modalCapsuleEdit" style='display:none'>
1 www 2219
 
6976 nelberth 2220
 
15139 stevensc 2221
	<!-- Modal Header -->
1 www 2222
 
15139 stevensc 2223
	<div class="d-flex justify-content-center tituloEditor">
2224
		<h4>LABEL_EDIT_CAPSULE</h4>
6976 nelberth 2225
 
15139 stevensc 2226
	</div>
2227
	<!-- Modal body -->
2228
	<div class="grid-padre">
2229
		<?php
2230
		$form = $this->formEdit;
2231
		$form->setAttributes([
2232
			'method'    => 'post',
2233
			'name'      => 'form-capsule-edit',
2234
			'id'        => 'form-capsule-edit'
2235
		]);
1 www 2236
 
15139 stevensc 2237
		$form->prepare();
2238
		echo $this->form()->openTag($form);
2239
		?>
2240
		<div class="form-group grid-1-2">
2241
			<?php
2242
			$element = $form->get('name');
1 www 2243
 
15139 stevensc 2244
			$element->setAttributes(['class' => 'form-control']);
2245
			$element->setOptions(['label' => 'LABEL_NAME']);
2246
			echo $this->formLabel($element);
2247
			echo $this->formText($element);
2248
			?>
2249
		</div>
2250
		<div class="form-group grid-1-2">
2251
			<?php
2252
			$element = $form->get('description');
2253
			$element->setAttributes(['id' => 'description_edit', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
2254
			$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
2255
			echo $this->formLabel($element);
2256
			echo $this->formTextArea($element);
2257
			?>
2258
		</div>
2259
		<div class="form-group grid-1-2">
2260
			<?php
2261
			$element = $form->get('order');
2262
			$element->setAttributes(['class' => 'form-control']);
2263
			$element->setOptions(['label' => 'LABEL_ORDER']);
2264
			echo $this->formLabel($element);
2265
			echo $this->formText($element);
2266
			?>
2267
		</div>
1 www 2268
 
15139 stevensc 2269
		<div class="form-group grid-1-2">
2270
			<?php
2271
			$element = $form->get('status');
2272
			$element->setAttributes(['class' => 'form-control']);
2273
			$element->setOptions(['label' => 'LABEL_STATUS']);
2274
			echo $this->formLabel($element);
2275
			echo $this->formSelect($element);
2276
			?>
2277
		</div>
2278
		<div class="form-group grid-1-2">
2279
			<?php
2280
			$element = $form->get('privacy');
2281
			$element->setAttributes(['class' => 'form-control']);
2282
			$element->setOptions(['label' => 'LABEL_PRIVACY']);
2283
			echo $this->formLabel($element);
2284
			echo $this->formSelect($element);
2285
			?>
2286
		</div>
2287
		<div class="form-group grid-1-2">
2288
			<?php
2289
			$element = $form->get('type');
2290
			$element->setAttributes(['class' => 'form-control']);
2291
			$element->setOptions(['label' => 'LABEL_TYPE']);
2292
			echo $this->formLabel($element);
2293
			echo $this->formSelect($element);
2294
			?>
2295
		</div>
2296
		<div class="form-group grid-1-2" id="form-row-cost">
2297
			<?php
2298
			$element = $form->get('cost');
2299
			$element->setAttributes(['class' => 'form-control']);
2300
			$element->setOptions(['label' => 'LABEL_COST']);
2301
			echo $this->formLabel($element);
2302
			echo $this->formText($element);
2303
			?>
2304
		</div>
1 www 2305
 
15139 stevensc 2306
		<?php
2307
		$element = $form->get('marketplace');
2308
		$element->setAttributes(['class' => 'marketplace']);
2309
		echo $this->formHidden($element);
2310
		?>
2311
		<?php
2312
		$element = $form->get('file');
2313
		$element->setAttributes(['class' => 'file']);
2314
		echo $this->formHidden($element);
2315
		?>
2316
		<div class="form-group grid-1-2 ">
2317
			<div class="imagen-contaner">
2318
				<label for="marketplaceImg">LABEL_IMAGE_MARKETPLACE</label>
2319
				<img class='marketplaceImg' src='' class="img img-responsive" style="width: 100px; height: auto"></img>
2320
			</div>
2321
		</div>
2322
		<h5 style="text-align:center " class="form-group grid-1-2" id='titleTypeImage'>LABEL_IMAGE_MARKETPLACE</h5>
2323
		<div class="contenido form-group " id="contenido"></div>
2324
 
2325
		<?php echo $this->form()->closeTag($form); ?>
2326
	</div>
2327
 
2328
 
2329
</div>
2330
 
2331
 
2332
 
1 www 2333
<!-- The Modal -->
2334
<div class="modal" id="modalAppMarkeplate">
2335
	<div class="modal-dialog">
2336
		<div class="modal-content">
15139 stevensc 2337
			<!-- Modal Header -->
2338
			<div class="modal-header">
2339
				<h4 class="modal-title">LABEL_IMAGE_MARKETPLACE</h4>
2340
				<button type="button" class="close" data-dismiss="modal">&times;</button>
2341
			</div>
1 www 2342
 
15139 stevensc 2343
			<!-- Modal body -->
2344
			<div class="modal-body text-center">
2345
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-marketplace" />
2346
			</div>
2347
 
2348
			<!-- Modal footer -->
2349
			<div class="modal-footer">
2350
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
2351
			</div>
2352
		</div>
1 www 2353
	</div>
15139 stevensc 2354
</div>
1 www 2355
 
2356
 
2357
<!-- The Modal -->
2358
<div class="modal" id="modalImageApp">
2359
	<div class="modal-dialog ">
15139 stevensc 2360
		<div class="modal-content">
1 www 2361
 
15139 stevensc 2362
			<!-- Modal Header -->
2363
			<div class="modal-header">
2364
				<h4 class="modal-title">LABEL_IMAGE</h4>
2365
				<button type="button" class="close" data-dismiss="modal">&times;</button>
2366
			</div>
1 www 2367
 
15139 stevensc 2368
			<!-- Modal body -->
2369
			<div class="modal-body text-center">
1 www 2370
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-app" />
15139 stevensc 2371
			</div>
2372
 
2373
			<!-- Modal footer -->
2374
			<div class="modal-footer">
2375
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
2376
			</div>
2377
		</div>
1 www 2378
	</div>
15139 stevensc 2379
</div>
1 www 2380
 
2381
 
2382
 
15139 stevensc 2383
 
2384
 
2385
 
1 www 2386
<!-- The Modal -->
2387
<div class="modal" id="notificationUsersModal">
2388
	<div class="modal-dialog modal-xl">
15139 stevensc 2389
		<div class="modal-content">
1 www 2390
 
15139 stevensc 2391
			<!-- Modal Header -->
2392
			<div class="modal-header">
2393
				<h4 class="modal-title">LABEL_USERS</h4>
2394
				<button type="button" class="close" data-dismiss="modal">&times;</button>
2395
			</div>
1 www 2396
 
15139 stevensc 2397
			<!-- Modal body -->
2398
			<div class="modal-body">
2399
				<form>
2400
					<div class="form-group">
2401
						<label>LABEL_TOPIC</label>
2402
						<input type="text" readonly="readonly" id="table-users-topic" class="form-control">
2403
					</div>
2404
					<div class="form-group">
2405
						<label>LABEL_CAPSULE</label>
2406
						<input type="text" readonly="readonly" id="table-users-capsule" class="form-control">
2407
					</div>
2408
				</form>
2409
				<div style="height: 300px;overflow: scroll;">
2410
					<table id="gridTableUsers" style="width: 100%" class="table   table-hover">
2411
						<thead>
2412
							<tr>
2413
								<th>LABEL_FIRST_NAME</th>
2414
								<th>LABEL_LAST_NAME</th>
2415
								<th>LABEL_EMAIL</th>
2416
								<th>LABEL_DETAILS</th>
2417
							</tr>
2418
						</thead>
2419
						<tbody>
2420
						</tbody>
2421
					</table>
2422
				</div>
1 www 2423
 
15139 stevensc 2424
			</div>
1 www 2425
 
15139 stevensc 2426
			<!-- Modal footer -->
2427
			<div class="modal-footer">
2428
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
2429
			</div>
2430
 
2431
		</div>
15027 stevensc 2432
	</div>
15139 stevensc 2433
</div>