Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
15026 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
 
18
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
19
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
20
 
21
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
22
 
23
 
24
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/css/fileinput.min.css'));
25
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.css'));
26
 
27
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/piexif.js'));
28
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/sortable.js'));
29
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/fileinput.js'));
30
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/locales/es.js'));
31
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/fas/theme.js'));
32
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.js'));
33
 
34
 
35
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
36
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
37
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
38
 
39
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
40
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
41
 
42
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
43
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
44
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
45
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
46
 
6701 nelberth 47
$this->headLink()->appendStylesheet($this->basePath('plugins/nelberth-editor/style.css'));
1 www 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'])
15026 stevensc 612
					if(imageEdit){
613
						$("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
614
					}else{
615
						$("#boton_recortar").removeClass("recortar").text("LABEL_ATTACH_IMAGE").addClass("info_noticia");
616
					}
617
 
1 www 618
                } else {
619
                    validatorEdit.resetForm();
620
                    if(jQuery.type(response['data']) == 'string') {
621
                        $.fn.showError(response['data']);
622
                    } else  {
623
                        $.each(response['data'], function( fieldname, errors ) {
624
                            $.fn.showFormErrorValidator('#form-capsule-edit #' + fieldname, errors);
625
                        });
626
                    }
627
                }
628
            }).fail(function( jqXHR, textStatus, errorThrown) {
629
                $.fn.showError(textStatus);
630
            }).always(function() {
631
                NProgress.done();
632
            });
633
        });
634
 
6886 nelberth 635
 
1 www 636
 
637
 
8290 stevensc 638
        CKEDITOR.replace('description_add', {
639
			toolbar: [
640
                    { name: 'editing', items: ['Scayt'] },
641
                    { name: 'links', items: ['Link', 'Unlink'] },
642
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
643
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
644
                    '/',
645
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
646
                    { name: 'styles', items: ['Styles', 'Format'] },
647
                    { name: 'tools', items: ['Maximize'] }
648
                ],
649
                removePlugins: 'elementspath,Anchor',
650
                heigth: 100
651
		});
652
        CKEDITOR.replace('description_edit', {
653
			toolbar: [
654
                    { name: 'editing', items: ['Scayt'] },
655
                    { name: 'links', items: ['Link', 'Unlink'] },
656
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
657
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
658
                    '/',
659
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
660
                    { name: 'styles', items: ['Styles', 'Format'] },
661
                    { name: 'tools', items: ['Maximize'] }
662
                ],
663
                removePlugins: 'elementspath,Anchor',
664
                heigth: 100
665
		});
1 www 666
 
667
        $('#form-capsule-add #type').change(function(e) {
668
            e.preventDefault();
669
 
670
            if('s' == $(this).val()) {
671
                $('#form-capsule-add #form-row-cost').show();
672
            } else {
673
                $('#form-capsule-add #cost').val(0);
674
                $('#form-capsule-add #form-row-cost').hide();
675
            }
676
 
677
        });
678
 
679
        $('#form-capsule-edit #type').change(function(e) {
680
            e.preventDefault();
681
 
682
            if('s' == $(this).val()) {
683
                $('#form-capsule-edit #form-row-cost').show();
684
            } else {
685
                $('#form-capsule-edit #cost').val(0);
686
                $('#form-capsule-edit #form-row-cost').hide();
687
            }
688
 
689
        });
690
 
691
        $('#form-capsule-add #order').inputNumberFormat({decimal: 0});
692
        $('#form-capsule-add #cost').inputNumberFormat({decimal: 2});
693
 
694
        $('#form-filter #topic_uuid').change(function(e) {
695
            e.preventDefault();
696
 
697
            gridTable.api().ajax.reload(null, false);
698
 
699
        });
700
 
701
 
702
 
703
 
704
 
705
    $('body').on('click', 'button.btn-view-total-users', function(e) {
706
        e.preventDefault();
707
 
708
        var href = $(this).data('href');
709
        NProgress.start();
710
        $.ajax({
711
            'dataType'  : 'json',
712
            'accept'    : 'application/json',
713
            'method'    : 'get',
714
            'url'       : href,
715
        }).done(function(response) {
716
            if(response['success']) {
717
 
718
                $('#table-users-topic').val(response['data']['topic']);
719
      			$('#table-users-capsule').val(response['data']['capsule']);
720
 
721
                $('#gridTableUsers tbody').empty();
722
 
723
                $.each(response['data']['items'], function(index, item) {
724
 
725
                    console.log(item);
726
 
727
                    var s = '<tr>';
728
                    s = s + '<td>' + item['first_name'] + '</td>';
729
                    s = s + '<td>' + item['last_name'] + '</td>';
730
                    s = s + '<td>' + item['email'] + '</td>';
731
 
732
                    s = s + '<td>';
733
                    if(item['details']['access']) {
734
                        s = s + 'LABEL_ACCESS : ' + item['details']['access'] + '<br>';
735
                    }
736
                    if(item['details']['paid_from']) {
737
                        s = s + 'LABEL_PAID_FROM : ' + item['details']['paid_from'] + '<br>';
738
                    }
739
                    if(item['details']['paid_to']) {
740
                        s = s + 'LABEL_PAID_TO : ' + item['details']['paid_to'] + '<br>';
741
                    }
742
 
743
                    s = s + '</td>';
744
                    s = s + '</tr>';
745
 
746
                    $('#gridTableUsers tbody').append(s);
747
 
748
 
749
                });
750
 
751
                $('#notificationUsersModal').modal('show');
752
 
753
            } else {
754
                $.fn.showError(response['data']);
755
 
756
            }
757
        }).fail(function( jqXHR, textStatus, errorThrown) {
758
            $.fn.showError(textStatus);
759
        }).always(function() {
760
 
761
            NProgress.done();
762
        });
763
        return false;
764
 
765
    });
766
    $('body').on('click', 'button.btn-refresh', function(e) {
767
        e.preventDefault();
768
        gridTable.api().ajax.reload(null, false);
769
    });
6682 nelberth 770
       	/*Script del editor (Aqui comienza el cielo y la tierra) */
6863 nelberth 771
 
772
		var fileToggle=true;
6886 nelberth 773
		$('body').on('click', '#ir_atras', function(e) {
774
            e.preventDefault();
775
			if(fileToggle){
6985 nelberth 776
				imagenEdit='';
6886 nelberth 777
            	$('body, html').animate({scrollTop: '0px'}, 300);
778
				$('#content1').css('display','block');
779
           		seleccionarCampo.css('display','none');
780
            	$('.contenido').html('');
6997 nelberth 781
				$('.marketplaceImg').attr('src', '')
6886 nelberth 782
			}else{
7000 nelberth 783
				$('#titleTypeImage').html('LABEL_IMAGE_MARKETPLACE')
6997 nelberth 784
				$('.marketplaceImg').attr('src', '')
6964 nelberth 785
				fileToggle=true;
6890 nelberth 786
				iniciarEditor(seleccionarCampo,imagenServidorNoticia,false)
6964 nelberth 787
 
6886 nelberth 788
			}
789
            return false;
790
        });
6984 nelberth 791
		var imagenEdit='';
6682 nelberth 792
		var imagenServidorNoticia;
793
		var scroll_altura,viente;
794
		var nombre_user = $(".perfil_u_nombre").text();
795
		var primer_nombre = nombre_user.split(" ")[0];
11027 nelberth 796
		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>'
797
 
6966 nelberth 798
		var pw=420,ph=320;
6682 nelberth 799
		$(document).on("click", ".info_noticia", function(e){
800
			imagenServidorNoticia = elemento.toDataURL("image/jpeg", 1.0);
6863 nelberth 801
			if(fileToggle){
6864 nelberth 802
				e.preventDefault();
6863 nelberth 803
				setTimeout(function(){
6972 nelberth 804
 
6997 nelberth 805
					$('.marketplaceImg').attr('src', imagenServidorNoticia)
7000 nelberth 806
					$('#titleTypeImage').html('LABEL_IMAGE')
6863 nelberth 807
					fileToggle=false;
6984 nelberth 808
					if(imagenEdit==""){
809
						iniciarEditor(seleccionarCampo)
810
					}else{
811
						iniciarEditor(seleccionarCampo,imagenEdit)
812
					}
6925 nelberth 813
 
6863 nelberth 814
				},$('.marketplace').val(imagenServidorNoticia.split(',')[1]));
815
			}else{
816
				$('.file').val(imagenServidorNoticia.split(',')[1]);
6946 nelberth 817
 
6863 nelberth 818
			}
819
 
6682 nelberth 820
			console.log($('.file').val())
6874 nelberth 821
			console.log($('.marketplace').val())
6682 nelberth 822
			$(".c1").addClass("paso");
1 www 823
 
6682 nelberth 824
 
825
		})
8582 nelberth 826
		var edit;
6889 nelberth 827
		function iniciarEditor(campo, image='',load=true){
6682 nelberth 828
		 cortar=false;
829
		recorte_listo=false;
830
		texto="";
831
		seis=true;
832
		color="#ffffff";
833
		texto_listo=false,siete=false;
834
		uno=true;
835
		size=48;
836
		cinco=true;
11038 nelberth 837
		blockCelda=false;
6952 nelberth 838
		if(fileToggle){
6970 nelberth 839
			pw=420; ph=320;
840
			recorte=ph/pw;
6952 nelberth 841
		}else{
6970 nelberth 842
			pw=320; ph=480;
843
			recorte=ph/pw;
6952 nelberth 844
		}
845
 
6926 nelberth 846
		xf=pw,yf =ph;
6682 nelberth 847
		negritas=false, bold="";
848
		shadow = true, nueve=true;
849
		italic=false, ita="";
850
		rectangulo=false, diez=false;
851
     	fontfamily="Arial";
852
     	r=0,g=0,b=0,a=1;
853
		window.clearInterval(editorNoticia);
854
		setTimeout(function(){
6959 nelberth 855
			if(fileToggle){
856
				$('#imagen_noticias').css({
857
					'height': '320px',
858
    				'width': '420px',
859
				})
6999 nelberth 860
				$('.cuadro_noticias').addClass('tienda')
6959 nelberth 861
 
6965 nelberth 862
			}else{
863
				$('#imagen_noticias').css({
864
					'height': '480px',
865
    				'width': '320px',
866
				})
6999 nelberth 867
				$('.cuadro_noticias').removeClass('tienda')
6959 nelberth 868
			}
6971 nelberth 869
			console.log(ph+'  '+pw)
6682 nelberth 870
			scroll_altura=$(".articulo_noticia").offset().top-110;
871
			anchoFondoOscuro = $(".articulo_noticia").width();
872
			altoFondoOscuro = $(".editor_imagenes").height();
873
 
6889 nelberth 874
		},navegacion(nuevoHtmlImagen,campo,image,load));
6682 nelberth 875
 
876
		}
877
 
878
		$(document).on("click", ".volver", function(){
879
		var nombre_user = $(".perfil_u_nombre").text();
880
		var primer_nombre = nombre_user.split(" ")[0];
881
		 cortar=false;
882
		cinco=true;
883
		recorte_listo=false;
884
		texto="";
885
		seis=true;
886
		color="#ffffff";
887
		texto_listo=false,siete=false;
888
		uno=true;
889
		size=48;
6960 nelberth 890
		if(fileToggle){
891
			pw=420, ph=320;
6967 nelberth 892
			recorte=ph/pw
6960 nelberth 893
		}else{
894
			pw=320, ph=480;
6967 nelberth 895
			recorte=ph/pw
6960 nelberth 896
		}
6926 nelberth 897
		xf=pw,yf =ph;
11038 nelberth 898
		blockCelda=false;
6682 nelberth 899
		negritas=false, bold="";
900
		shadow = true, nueve=true;
901
		italic=false, ita="";
902
		rectangulo=false, diez=false;
903
     	fontfamily="Arial";
904
     	r=0,g=0,b=0,a=1;
905
		 var imagenServidorNoticia;
906
         console.log(seleccionarCampo)
907
		window.clearInterval(editorNoticia);
908
		setTimeout(function(){
6960 nelberth 909
			if(fileToggle){
910
				$('#imagen_noticias').css({
911
					'height': '320px',
912
    				'width': '420px',
913
				})
11258 nelberth 914
				$('.cuadro_noticias').addClass('tienda')
6960 nelberth 915
 
11258 nelberth 916
			}else{
917
				$('#imagen_noticias').css({
918
					'height': '480px',
919
    				'width': '320px',
920
				})
921
				$('.cuadro_noticias').removeClass('tienda')
6960 nelberth 922
			}
6682 nelberth 923
			scroll_altura=$(".articulo_noticia").offset().top-110;
924
			anchoFondoOscuro = $(".articulo_noticia").width();
925
			altoFondoOscuro = $(".editor_imagenes").height();
926
 
927
		},navegacion(nuevoHtmlImagen,seleccionarCampo));
928
 
929
		})
930
 
6889 nelberth 931
		function navegacion(nuevoHtmlImagen,campo,image='',load=true){
6682 nelberth 932
                selectorElementoName=campo.find('#name')
8583 nelberth 933
 
6824 nelberth 934
                selectorElementoEditor=campo.find('#contenido');
8584 nelberth 935
				edit=true;
6682 nelberth 936
				if(image!=''){
8585 nelberth 937
					edit=false;
6889 nelberth 938
					if(load){
8585 nelberth 939
 
8583 nelberth 940
 
6888 nelberth 941
						const getBase64FromUrl = async (url) => {
942
							const data = await fetch(url);
943
							const blob = await data.blob();
944
							return new Promise((resolve) => {
945
								const reader = new FileReader();
946
								reader.readAsDataURL(blob);
947
								reader.onloadend = function() {
948
								const base64data = reader.result;
949
								resolve(base64data);
950
								}
951
							});
952
						}
8583 nelberth 953
 
6888 nelberth 954
						getBase64FromUrl(image).then(function(e){
955
							selectorElementoName.trigger('change');
956
							$(".volver").css("display","block")
957
							$(".a1").addClass("paso");
958
							$(".titulo_pasos").html("LABEL_STEP_2");
959
							setTimeout(function(){
960
								recorte_listo=true;
961
								$(".fondo_oscuro").css("display","none");
6989 nelberth 962
								if(fileToggle){
7000 nelberth 963
									$("#boton_recortar").removeClass("recortar").text("LABEL_ATTACH_IMAGE").addClass("info_noticia");
6989 nelberth 964
									}else{
965
									$("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
966
								}
6888 nelberth 967
								$(".recortar10").removeClass("recortar");
968
								$(".canvas").removeClass("recortar");
969
								$(".b1").addClass("paso");
970
								$(".titulo_pasos").html("LABEL_STEP_3");
971
								if(texto!=""){
972
									seis=true;
973
									siete=true;
974
								}
975
								cinco=true;
976
								dos=true;
977
								cuatro=true;
978
								actualizar();
979
 
980
							},editorNoticia(e));
981
 
982
 
983
						})
6891 nelberth 984
						setTimeout(function(){
7000 nelberth 985
							$(".canvas_subir").html('<span class="icon-plus fa fa-spinner"></span> LABEL_LOADING...')
6891 nelberth 986
							selectorElementoName.trigger('change');
987
						},selectorElementoEditor.html(nuevoHtmlImagen));
6888 nelberth 988
					}else{
6682 nelberth 989
						selectorElementoName.trigger('change');
6891 nelberth 990
						setTimeout(function(){
6888 nelberth 991
							$(".volver").css("display","block")
992
							$(".a1").addClass("paso");
993
							$(".titulo_pasos").html("LABEL_STEP_2");
994
							setTimeout(function(){
6905 nelberth 995
								recorte_listo=true;
6888 nelberth 996
								$(".fondo_oscuro").css("display","none");
6987 nelberth 997
								if(fileToggle){
998
 
7000 nelberth 999
									$("#boton_recortar").removeClass("recortar").text("LABEL_ATTACH_IMAGE").addClass("info_noticia");
6988 nelberth 1000
								}else{
6987 nelberth 1001
									$("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
1002
 
1003
								}
6888 nelberth 1004
								$(".recortar10").removeClass("recortar");
1005
								$(".canvas").removeClass("recortar");
1006
								$(".b1").addClass("paso");
1007
								$(".titulo_pasos").html("LABEL_STEP_3");
1008
								if(texto!=""){
1009
									seis=true;
1010
									siete=true;
1011
								}
1012
								cinco=true;
1013
								dos=true;
1014
								cuatro=true;
1015
								actualizar();
6682 nelberth 1016
 
6888 nelberth 1017
							},editorNoticia(image));
6891 nelberth 1018
 
1019
 
1020
							selectorElementoName.trigger('change');
1021
						},selectorElementoEditor.html(nuevoHtmlImagen));
6888 nelberth 1022
					}
6891 nelberth 1023
 
6682 nelberth 1024
				}else{
1025
					setTimeout(function(){
1026
					    selectorElementoName.trigger('change');
1027
					},selectorElementoEditor.html(nuevoHtmlImagen));
1028
				}
1029
 
1030
		}
1031
 
1032
		$(window).on("scroll", function(){
1033
			console.log(scroll_altura)
1034
		if($(window).scrollTop()>scroll_altura){
1035
			$("#cuadro_noticias").addClass("fixed");
1036
		}else{
1037
			$("#cuadro_noticias").removeClass("fixed");
1038
		}
1039
	})
1040
 
1041
	$(document).on("dragover", "#imagen_noticia", function(e){
1042
		e.preventDefault();
1043
		e.stopPropagation();
1044
		$(this).css({"background":"rgba(0,0,0,.2)"})
1045
	})
11259 nelberth 1046
 
11260 nelberth 1047
	$(window).resize(function() {
11259 nelberth 1048
		anchoFondoOscuro = $(".articulo_noticia").width();
1049
		altoFondoOscuro = $(".editor_imagenes").height();
11260 nelberth 1050
		setTimeout(function(){
1051
			anchoFondoOscuro = $(".articulo_noticia").width();
1052
			altoFondoOscuro = $(".editor_imagenes").height();
1053
		},300)
11259 nelberth 1054
 
1055
	});
11260 nelberth 1056
 
6682 nelberth 1057
	$(document).on("drop", "#imagen_noticia", function(e){
1058
		e.preventDefault();
1059
		e.stopPropagation();
1060
		$(this).css("background", "none");
1061
		var archivo = e.originalEvent.dataTransfer.files;
1062
		var img=archivo[0];
1063
		if(img.type =="image/jpeg"||img.type =="image/png"){
1064
			$(".modificar").removeClass("animated");
1065
			var render = new FileReader();
1066
			render.readAsDataURL(img);
1067
			render.onload = function(e){
8354 nelberth 1068
				imagen2=new Image();
1069
				imagen2.src=e.target.result;
1070
 
1071
				$(imagen2).ready(function(e){
11030 nelberth 1072
					if(imagen2.width<320||imagen2.height<480){
8360 nelberth 1073
						$.fn.showError('LABEL_MINIMUM_IMAGE_SIZE');
8354 nelberth 1074
					}else{
1075
						$(".volver").css("display","block")
1076
						$(".a1").addClass("paso");
1077
						$(".titulo_pasos").html("LABEL_STEP_2");
1078
						editorNoticia(imagen2.src)
1079
					}
1080
				})
1081
			}
1082
		}else{
8360 nelberth 1083
			$.fn.showError('LABEL_SUPPORTED_FORMATS');
6682 nelberth 1084
		}
1085
	})
11030 nelberth 1086
	$(document).on("change", "#imagen_noticia_file", function(e){
1087
		file = $(this)[0].files[0];
1088
		e.preventDefault();
1089
		$(this).css("background", "none");
1090
		var archivo = file;
1091
		var img=file;
1092
		if(img.type =="image/jpeg"||img.type =="image/png"){
1093
			$(".modificar").removeClass("animated");
1094
			var render = new FileReader();
1095
			render.readAsDataURL(img);
1096
			render.onload = function(e){
1097
				imagen2=new Image();
1098
				imagen2.src=e.target.result;
1099
 
1100
				$(imagen2).ready(function(e){
1101
					if(imagen2.width<320||imagen2.height<480){
1102
						$.fn.showError('LABEL_MINIMUM_IMAGE_SIZE');
1103
					}else{
1104
						$(".volver").css("display","block")
1105
						$(".a1").addClass("paso");
1106
						$(".titulo_pasos").html("LABEL_STEP_2");
1107
						editorNoticia(imagen2.src)
1108
					}
1109
				})
1110
			}
1111
		}else{
1112
			$.fn.showError('LABEL_SUPPORTED_FORMATS');
1113
		}
1114
	})
6682 nelberth 1115
	$(document).on("dragover", "body", function(e){
1116
		e.preventDefault();
1117
		e.stopPropagation();
1118
	})
1119
	$(document).on("drop", "body", function(e){
1120
		e.preventDefault();
1121
		e.stopPropagation();
1122
	})
1123
 
1124
	var canvas='<div class="editorNoticia"><canvas id="editorNoticia">LABEL_NOT_SUPPORTED</canvas></div>';
1125
	$(document).on("mouseover", ".editorNoticia", function(){
12344 nelberth 1126
		const getScrollBarWidth = () => window.innerWidth - document.documentElement.getBoundingClientRect().width
1127
		let anchoScroll= getScrollBarWidth()+"px";
6682 nelberth 1128
		$("body").css({"overflow": "hidden"});
12344 nelberth 1129
		$(".cuadro_noticias, .fixed_noticia,.tituloEditor,.grid-padre,.subpanel").css("margin-right",anchoScroll )
1130
		$(".barra,.footer").css("padding-right",anchoScroll)
6682 nelberth 1131
 
12344 nelberth 1132
 
6682 nelberth 1133
 
1134
	})
1135
	$(document).on("mouseover", "#editorNoticia", function(){
1136
		if(recorte_listo){
1137
			ocho=true;
1138
		}
1139
	})
1140
	$(document).on("mouseout", "#editorNoticia", function(){
1141
		if(recorte_listo){
1142
			ocho=false;
1143
			actualizar2()
1144
		}
1145
	})
1146
	$(document).on("mouseout", ".editorNoticia",function(){
1147
		$("body").css({"overflow": "auto"})
1148
		$(".cuadro_noticias, .fixed_noticia,.tituloEditor,.grid-padre").css("margin-right", "0px")
1149
		$(".barra,.footer").css("padding-right","0px")
1150
 
1151
	})
1152
	$(document).on('mousewheel', ".editorNoticia",function(e){
1153
		var ruedita = e.originalEvent.wheelDelta
1154
		if(ruedita>0){
1155
			scale = scale+(scale/10);
1156
			$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1157
		}else{
1158
			scale = scale-(scale/10);
1159
			$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1160
		}
1161
		$("#editorNoticia").css({"transform": "scale("+scale+")"});
1162
	})
1163
	$(document).on("click", ".as", function(e){
1164
		e.preventDefault();
1165
		 scale = $(this).data("scale");
1166
		 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
1167
		 $("#editorNoticia").css({"transform": "scale("+scale+")"});
1168
 
1169
	})
1170
	$(document).on("click", ".ps", function(e){
1171
		e.preventDefault();
1172
		$(".cantidades_scale").slideToggle(200).css("display", "block");
1173
	})
1174
	$(document).on("click", "#cerrar_filter_modal, .icon_filter", function(e){
1175
		e.preventDefault();
1176
		if(recorte_listo){
1177
		$(".contenido_filter").slideToggle(200).css("display", "block");
1178
		}
1179
	})
1180
	$(document).on("click", "#cerrar_text_modal, .icon_text", function(e){
1181
		e.preventDefault();
1182
		if(recorte_listo){
1183
			$(".contenido_text").slideToggle(200).css("display", "block");
1184
		}
1185
	})
1186
 
1187
	$(document).on("click", "#cerrar_cut_modal, .icon_cut", function(e){
1188
		e.preventDefault();
1189
		if(cortar){
1190
			$(".contenido_cut").slideToggle(200).css("display", "block");
1191
		}
1192
 
1193
	})
1194
	$(document).on("click", "#menos_scale", function(e){
1195
		e.preventDefault();
1196
		scale = scale-(scale/10);
1197
		 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
1198
		 $("#editorNoticia").css({"transform": "scale("+scale+")"});
1199
	})
1200
 
1201
	$(document).on("click", "#mas_scale", function(e){
1202
		e.preventDefault();
1203
		scale = scale+(scale/10);
1204
		 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
1205
		 $("#editorNoticia").css({"transform": "scale("+scale+")"});
1206
	})
11045 nelberth 1207
	$(document).on('change', '#selectFiltro', function(e){
1208
 
1209
		data=$(this).val()
1210
		if(data=="normal"){
1211
			filter();
1212
		}else{
1213
			data=data.split(',');
1214
			if(data[2]=='gris'){
1215
				filtergris(data[0],data[1]);
1216
			}else{
1217
				filter(Number(data[0]),Number(data[1]),Number(data[2]),Number(data[3]),Number(data[4]),Number(data[5]));
1218
			}
1219
		}
6682 nelberth 1220
	})
1221
	var texto_listo=false,siete=false;
11251 nelberth 1222
	var texto;
6682 nelberth 1223
	$(document).on("keyup", "#texto_input", function(e){
1224
		e.preventDefault();
1225
		texto = $(this).val();
1226
		if(texto_actualizar){
1227
			siete=true;
1228
		}
1229
		if(texto!=""){
1230
			texto_actualizar=true;
1231
			actualizar2();
1232
		}else{
1233
			actualizar2();
1234
		}
1235
 
1236
	})
1237
	var color="#ffffff";
11041 nelberth 1238
	$(document).on("change input", "#color", function(){
6682 nelberth 1239
    	color=$(this).val();
1240
    	seis=true;
1241
    	actualizar2();
1242
    })
11040 nelberth 1243
	$(document).on("keypress", "#font-size, #texto_input", function(e){
1244
    	if(e.which == 13){
1245
      		return false;
1246
    	}
1247
  	});
6682 nelberth 1248
    var size=48;
1249
    $(document).on("keyup change", "#font-size", function(){
1250
    	size=$(this).val();
1251
    	size = parseInt(size);
1252
    	seis=true;
1253
    	siete=true;
1254
    	actualizar2();
1255
    })
1256
    var negritas=false, bold="";
1257
    $(document).on("click", "#negritas", function(e){
1258
    	e.preventDefault();
1259
    	if(!negritas){
1260
    		bold="bold";
1261
    		$(this).addClass("fa");
1262
    		seis=true;
1263
    		siete=true;
1264
    		actualizar2();
1265
    		negritas=true;
1266
    	}else{
1267
    		bold="";
1268
    		$(this).removeClass("fa");
1269
    		seis=true;
1270
    		siete=true;
1271
    		actualizar2();
1272
    		negritas=false;
1273
    	}
1274
    })
1275
    var italic=false, ita="";
1276
     $(document).on("click", "#italic", function(e){
1277
    	e.preventDefault();
1278
    	if(!italic){
1279
    		ita="italic";
1280
    		$(this).addClass("fa");
1281
    		seis=true;
1282
    		siete=true;
1283
    		actualizar2();
1284
    		italic=true;
1285
    	}else{
1286
    		ita="";
1287
    		$(this).removeClass("fa");
1288
    		seis=true;
1289
    		siete=true;
1290
    		actualizar2();
1291
    		italic=false;
1292
    	}
1293
    })
11039 nelberth 1294
	var fontfamily="Arial";
1295
     $(document).on("change", "#selectFuente", function(e){
6682 nelberth 1296
    	e.preventDefault();
11039 nelberth 1297
    	fontfamily= $(this).val();
6682 nelberth 1298
    	seis=true;
1299
    	siete=true;
1300
    	actualizar2();
1301
 
1302
    })
1303
     var shadow = true, nueve=true;
1304
     $(document).on("click","#shadow", function(e){
1305
     	e.preventDefault();
1306
     	if(shadow){
1307
     		$(this).removeClass("fa");
1308
     		seis=true;
1309
     		nueve=false;
1310
     		actualizar2();
1311
     		shadow=false;
1312
     	}else{
1313
     		$(this).addClass("fa");
1314
     		seis=true;
1315
     		nueve=true;
1316
     		actualizar2();
1317
     		shadow=true;
1318
     	}
1319
 
1320
     })
1321
     var rectangulo=false, diez=false, colorrect="#000000";
11042 nelberth 1322
	 $(document).on("click", "#rectangulo", function(e){
6682 nelberth 1323
     	e.preventDefault();
1324
     	if(!rectangulo){
1325
     		$(this).addClass("fa");
11042 nelberth 1326
			$('.color_fondo_cuadro').css('display','flex')
6682 nelberth 1327
     		diez=true;
1328
     		actualizar2();
1329
     		rectangulo=true;
1330
     	}else{
1331
     		$(this).removeClass("fa");
11042 nelberth 1332
			 $('.color_fondo_cuadro').css('display','none')
6682 nelberth 1333
     		diez=false;
1334
     		actualizar2();
1335
     		rectangulo=false;
1336
     	}
1337
 
1338
     })
1339
     var r=0,g=0,b=0;
11043 nelberth 1340
	 $(document).on("change input", "#colorrect", function(){
6682 nelberth 1341
    	colorrect=$(this).val();
11043 nelberth 1342
    	r=parseInt(colorrect.slice(1,3),16);
1343
    	g=parseInt(colorrect.slice(3,5),16);
1344
    	b=parseInt(colorrect.slice(5,7),16);
6682 nelberth 1345
    	seis=true;
1346
    	actualizar2();
1347
    })
1348
    var a=1;
1349
 
11044 nelberth 1350
	$(document).on("mousemove change ", "#opacidad", function(){
6682 nelberth 1351
    	a=$(this).val();
1352
    	a=a/100;
1353
    	seis=true;
1354
    	actualizar2();
1355
    })
1356
	var imaNoti = new Image();
1357
	function filter(brillo=1, contraste=1, rojo=1, verde=1, azul=1, valor=1){
1358
		cuatro=false;
1359
		restaurar(brillo, contraste);
1360
		datos=imagenOriginal.data;
1361
		if(valor==2){
1362
			for (var i =  0; i <datos.length; i+=4) {
1363
				datos[i]=datos[i]+rojo;
1364
				datos[i+1]=datos[i+1]+verde;
1365
				datos[i+2]=datos[i+2]+azul;
1366
			}
1367
		}else{
1368
			for (var i =  0; i <datos.length; i+=4) {
1369
				datos[i]=datos[i]*rojo;
1370
				datos[i+1]=datos[i+1]*verde;
1371
				datos[i+2]=datos[i+2]*azul
1372
			}
1373
		}
1374
		editor.putImageData(imagenOriginal,0,0)
1375
		var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
1376
	    imaNoti.src = imagenNoticia;
1377
		actualizar2();
1378
	}
1379
	function filtergris(brillo=1, contraste=1){
1380
		cuatro=false;
1381
		restaurar(brillo, contraste);
1382
		datos=imagenOriginal.data;
1383
		var auxiliar;
1384
		for (var i =  0; i <datos.length; i+=4) {
8356 nelberth 1385
			auxiliar = 0.34 * datos[i] + 0.5 *datos[i+1] + 0.1/6 * datos[i+2];
6682 nelberth 1386
			datos[i]=auxiliar;
1387
			datos[i+1]=auxiliar;
1388
			datos[i+2]=auxiliar;
1389
		}
1390
 
1391
		editor.putImageData(imagenOriginal,0,0)
1392
		var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
1393
	    imaNoti.src = imagenNoticia;
1394
		actualizar2();
1395
	}
1396
	function restaurar(brillo = 1, contraste=1){
1397
		editor.filter = "none"
1398
		editor.filter = 'contrast('+contraste+') brightness('+brillo+') saturate(1) sepia(0)';
1399
		editor.fillStyle="rgba(255,255,255,1)"
1400
		editor.fillRect(0,0,ancho,alto);
1401
		editor.fillStyle=""+color+"";
1402
		var pxf=0,pyf=0;
1403
			if(xf>=(yf/recorte)){
1404
				pxf=xf/ancho;
1405
				pyf=yf/pxf;
1406
				py=(alto/2)-(pyf/2);
1407
				editor.drawImage(imagen,x,y,xf,yf,0,py,ancho,pyf);
1408
			}else{
1409
				pyf=yf/alto;
1410
				pxf=xf/pyf;
1411
				px=(ancho/2)-(pxf/2);
1412
				editor.drawImage(imagen,x,y,xf,yf,px,0,pxf,alto);
1413
			}
1414
		imagenOriginal = editor.getImageData(0,0,ancho,alto)
1415
	}
1416
	var ocho=false;
1417
	function actualizar2(){
1418
		if(recorte_listo){
1419
		if(cuatro){
1420
			imagenOriginal = editor.getImageData(0,0,ancho,alto)
1421
			var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
1422
	    	imaNoti.src = imagenNoticia;
1423
	    	cuatro=false;
1424
		}
1425
		editor.filter = "none"
1426
		$(imaNoti).ready(function(e){
6926 nelberth 1427
			noticia.drawImage(imaNoti,0,0,pw,ph);
6682 nelberth 1428
			editor.drawImage(imaNoti,0,0,ancho,alto)
1429
			if(texto_actualizar){
1430
				if(texto!=""){
1431
					if(seis){
1432
						ancho_imaNoti = imaNoti.width;
1433
 
6926 nelberth 1434
						scale_noticia = -(((ancho_imaNoti-pw)/ancho_imaNoti)-1);
6682 nelberth 1435
						editor.fillStyle=""+color+"";
1436
						editor.strokeStyle="rgb(255,255,255)";
1437
						if(nueve){
1438
							editor.shadowColor="rgba(0,0,0,.5)";
1439
							editor.shadowOffsetX=6;
1440
							editor.shadowOffsetY=6;
1441
							editor.shadowBlur=6;
1442
							noticia.shadowColor="rgba(0,0,0,.5)";
1443
							noticia.shadowOffsetX=6*scale_noticia;
1444
							noticia.shadowOffsetY=6*scale_noticia;
1445
							noticia.shadowBlur=6*scale_noticia;
1446
						}else{
1447
							editor.shadowColor="rgba(0,0,0,0)";
1448
							noticia.shadowColor="rgba(0,0,0,0)";
1449
						}
1450
						editor.font=""+ita+" "+bold+" "+size+"px "+fontfamily+"";
1451
						editor.textAlign="start";
1452
						editor.textBaseline="top";
1453
 
1454
						var sizeNoticia = size*scale_noticia;
1455
						noticia.fillStyle=""+color+"";
1456
						noticia.font=""+ita+" "+bold+" "+sizeNoticia+"px "+fontfamily+"";
1457
						noticia.textAlign="start";
1458
						noticia.textBaseline="top";
1459
						seis=false;
1460
					}
1461
					if(siete){
1462
						dimencionesTexto = editor.measureText(texto);
1463
						txf=dimencionesTexto.width+20;
1464
						tyf= (20+size);
1465
						siete=false;
1466
					}
1467
					if(cinco){
1468
						dimencionesTexto = editor.measureText(texto);
1469
						if(xf>=(yf/recorte)){
1470
							tx=(xf/2)-(dimencionesTexto.width/2);
1471
							ty=(xf*recorte/2)-(size/2);
1472
						}else{
1473
							tx=(yf/recorte/2)-(dimencionesTexto.width/2);
1474
							ty=(yf/2)-(size/2);
1475
						}
1476
 
1477
						txf=dimencionesTexto.width+20;
1478
						tyf= size+20;
1479
						cinco=false;
1480
					}
1481
					if(diez){
1482
						editor.fillStyle="rgba("+r+","+g+","+b+","+a+")";
1483
						noticia.fillStyle="rgba("+r+","+g+","+b+","+a+")";
1484
						editor.fillRect(tx-10,ty-10,txf,tyf);
1485
						noticia.fillRect(((tx-10)*scale_noticia),((ty-10)*scale_noticia),txf*scale_noticia,tyf*scale_noticia);
1486
						editor.fillStyle=""+color+"";
1487
						noticia.fillStyle=""+color+"";
1488
 
1489
					}
1490
					editor.fillText(texto,tx,ty);
1491
					noticia.fillText(texto,(tx*scale_noticia),ty*scale_noticia);
1492
					if(ocho){
1493
						editor.strokeRect(tx-10,ty-10,txf,tyf)
1494
						editor.arc(tx+txf,ty+tyf,10,0,Math.PI*2,false);
1495
						editor.fill();
1496
						editor.beginPath();
1497
					}
1498
					texto_listo=true;
1499
				}
1500
			}
1501
		})
1502
 
1503
	}
1504
	}
1505
	function actualizar(){
6962 nelberth 1506
 
6961 nelberth 1507
			$(imagen).ready(function(e){
1508
 
6682 nelberth 1509
				if(uno){
6962 nelberth 1510
					elemento2.height=ph;
6964 nelberth 1511
					elemento2.width=pw;
6682 nelberth 1512
					ancho=imagen.width, alto = imagen.height;
1513
					elemento.width = ancho;
1514
					elemento.height = alto;
6956 nelberth 1515
 
6682 nelberth 1516
					$(".scale").css("display","flex");
1517
					if(ancho<=alto){
1518
					 scale = -(((alto-450)/alto)-1);
8357 nelberth 1519
 
1520
 
6682 nelberth 1521
					}else{
1522
					 scale = -(((ancho-500)/ancho)-1);
8357 nelberth 1523
 
6682 nelberth 1524
					}
11033 nelberth 1525
					scale=scale*0.80;
8579 nelberth 1526
					if(edit){
1527
						if((ancho*recorte)<=alto){
1528
							xf=ancho*.70;
1529
							yf=xf*recorte;
1530
						}else{
1531
							yf=alto*.70;
1532
							xf=yf/recorte;
1533
						}
1534
					}
8357 nelberth 1535
					cuadro_dimencion=Math.round(12/scale);
1536
 
1537
					if(xf<50||yf<50){
1538
						xf=50;
1539
						yf=xf*recorte;
1540
					}
1541
					mitadX=ancho/2;
1542
					mitadY=alto/2;
1543
					x=mitadX-xf/2;
1544
					y=mitadY-yf/2;
1545
 
6682 nelberth 1546
					$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1547
					$("#ancho").html(ancho+"px");
1548
					$("#alto").html(alto+"px");
1549
					uno=false;
1550
				}
1551
				if(dos){
1552
 
1553
					if(xf>=(yf/recorte)){
1554
						alto=xf*recorte;
1555
						ancho=xf;
1556
					}else{
1557
						ancho=yf/recorte;
1558
						alto=yf;
1559
 
1560
					}
1561
					elemento.width = ancho;
1562
					elemento.height = alto;
6963 nelberth 1563
					elemento2.height=ph;
1564
					elemento2.width=pw;
6682 nelberth 1565
					if(xf<=yf){
1566
					 scale = -(((yf-450)/yf)-1);
1567
 
1568
					}else{
1569
					 scale = -(((xf-500)/xf)-1);
1570
					}
1571
 
1572
					$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1573
					$("#ancho").html(Math.round(xf)+"px");
1574
					$("#alto").html(Math.round(yf)+"px");
1575
					dos=false;
1576
				}
1577
 
1578
					var pxf=0,pyf=0;
1579
					noticia.fillStyle="rgba(255,255,255,1)"
6926 nelberth 1580
					noticia.fillRect(0,0,pw,ph);
6682 nelberth 1581
				if(xf>=(yf/recorte)){
6926 nelberth 1582
					pxf=xf/pw;
6682 nelberth 1583
					pyf=yf/pxf;
6926 nelberth 1584
					py=(ph/2)-(pyf/2);
1585
					noticia.drawImage(imagen,x,y,xf,yf,0,py,pw,pyf);
6682 nelberth 1586
				}else{
6926 nelberth 1587
					pyf=yf/ph;
6682 nelberth 1588
					pxf=xf/pyf;
6926 nelberth 1589
					px=(pw/2)-(pxf/2);
1590
					noticia.drawImage(imagen,x,y,xf,yf,px,0,pxf,ph);
6682 nelberth 1591
				}
1592
 
1593
				$("#editorNoticia").css({"transform": "scale("+scale+")"});
1594
				if(!recorte_listo){
1595
					editor.drawImage(imagen,0,0,ancho,alto);
1596
					editor.fillStyle="rgba(0,0,0,.2)"
1597
					editor.fillRect(0,0,ancho,alto);
8358 nelberth 1598
					editor.fillStyle="rgba(255,255,255,.2)"
6682 nelberth 1599
					editor.fillRect(x,y,xf,yf);
8358 nelberth 1600
					editor.fillStyle="rgba(255,255,255,0.8)"
8356 nelberth 1601
					editor.fillRect(x,y,cuadro_dimencion,cuadro_dimencion);
1602
					editor.fillRect((x+xf)-cuadro_dimencion,y,cuadro_dimencion,cuadro_dimencion);
1603
					editor.fillRect(x,y+yf-cuadro_dimencion,cuadro_dimencion,cuadro_dimencion);
1604
					editor.fillRect(x+xf-cuadro_dimencion,yf+y-cuadro_dimencion,cuadro_dimencion,cuadro_dimencion);
6682 nelberth 1605
					esta=true;
1606
				}else{
1607
					var pxf=0,pyf=0;
1608
 
1609
					editor.fillStyle="rgba(255,255,255,1)"
1610
					editor.fillRect(0,0,ancho,alto);
1611
					if(xf>=(yf/recorte)){
1612
						pxf=xf/ancho;
1613
						pyf=yf/pxf;
1614
						py=(alto/2)-(pyf/2);
1615
						editor.drawImage(imagen,x,y,xf,yf,0,py,ancho,pyf);
1616
					}else{
1617
						pyf=yf/alto;
1618
						pxf=xf/pyf;
1619
						px=(ancho/2)-(pxf/2);
1620
						editor.drawImage(imagen,x,y,xf,yf,px,0,pxf,alto);
1621
				}
1622
 
1623
				}
1624
			})
1625
		}
6966 nelberth 1626
	var imagenOriginal
6956 nelberth 1627
	var x,y,xf=pw,yf =ph, elemento,elemento2,editor,centro, total,scale,dimencionesTexto,ancho_imaNoti,
6682 nelberth 1628
	recorte_listo=false,alto,ancho,tx,ty,txf,tyf,cuatro=true,texto_actualizar=false,cinco=true,seis=true,cuatro;
6970 nelberth 1629
	var  mitadY,mitadX, uno=true,dos=false, recorte=ph/pw, imagen_noticias, scale_noticia, tres=true,rotar=false, cortar=false;;
8356 nelberth 1630
	var translateX, cuadro_dimencion;
6682 nelberth 1631
 
1632
	$(document).on("click", ".recortar10", function(e){
1633
 
1634
		e.preventDefault();
1635
		recorte_listo=false;
1636
		uno=true;
7000 nelberth 1637
		$("#boton_recortar").addClass("recortar").text("LABEL_CUT").removeClass("info_noticia");
1638
		$("#boton_recortar3").addClass("recortar").text("LABEL_CUT").removeClass("info_noticia3");
6682 nelberth 1639
		$(".contenido_text").css("display", "none");
1640
		$(".contenido_filter").css("display", "none");
1641
		$(".recortar10").addClass("recortar");
1642
		$(".canvas").addClass("recortar")
1643
		$(".oa").removeClass("oa");
1644
		$("#normal").addClass("oa");
1645
		$(".b1").removeClass("paso");
1646
		$(".titulo_pasos").html("LABEL_STEP_2");
1647
		window.clearInterval(actualizar2);
1648
		actualizar();
1649
 
1650
	})
1651
 
1652
 
1653
	blockCelda=true;
1654
	$(document).on("click", "#blockCelda", function(e){
1655
		e.preventDefault();
1656
		if(blockCelda){
1657
			$(this).html('<span class="fa fa-unlock"></span>')
1658
 
1659
			blockCelda=false;
1660
		}else{
1661
			$(this).html('<span class="fa fa-lock"></span>')
1662
			blockCelda=true;
1663
		}
1664
		t4=true;
1665
 
1666
	})
1667
	var imagen
1668
	function editorNoticia(img){
1669
		 cortar=true;
1670
		imagen= new Image();
1671
		$(".canvas").html(canvas);
1672
		elemento = document.getElementById("editorNoticia");
1673
		editor = elemento.getContext("2d");
1674
		elemento2 = document.getElementById("imagen_noticias");
1675
		noticia = elemento2.getContext("2d");
1676
 
1677
		$(document).on("click", ".boton_marino.recortar",function(e){
1678
			e.preventDefault();
1679
			recorte_listo=true;
1680
			$(".fondo_oscuro").css("display","none");
6863 nelberth 1681
			if(fileToggle){
15026 stevensc 1682
				$("#boton_recortar").removeClass("recortar").text("LABEL_ATTACH_IMAGE").addClass("info_noticia");
1683
			}else{
15025 stevensc 1684
				$("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
6863 nelberth 1685
			}
6682 nelberth 1686
			$(".recortar10").removeClass("recortar");
1687
			$(".canvas").removeClass("recortar");
1688
			$(".b1").addClass("paso");
1689
			$(".titulo_pasos").html("LABEL_STEP_3");
1690
			if(texto!=""){
1691
				seis=true;
1692
				siete=true;
1693
			}
1694
			cinco=true;
1695
			dos=true;
1696
			cuatro=true;
11252 nelberth 1697
			setTimeout(() => {
1698
				actualizar2();
1699
			}, actualizar());
1700
 
6682 nelberth 1701
		})
1702
 
1703
		var cli = false, t1= false, t2=false,t3=false,t4=false,tcli=false;
1704
		var mouse =[];
1705
 
1706
 
1707
		function raton(elemento, e){
1708
			return {
1709
				x:((e.pageX - elemento.offsetLeft - ((ancho/2)-((ancho*scale)/2)))/scale),
1710
				y:((e.pageY - elemento.offsetTop - ((alto/2)-((alto*scale)/2)))/scale)
1711
			}
1712
		}
1713
 
1714
		imagen.src=img;
1715
		$(".recortar10").addClass("recortar");
1716
		$("#boton_recortar").removeClass("boton_normal").addClass("recortar boton_marino").text("LABEL_CUT")
1717
		actualizar();
1718
 
1719
		$(elemento).mousemove(function(e){
1720
			mouse = raton(this, e);
1721
			//console.log("raton x: "+mouse.x+ " raton Y: " +mouse.y+ " tx: "+tx+" ty: "+ty+" txf:"+(txf+tx)+" tyf:"+(tyf+ty) )
1722
			if(!recorte_listo){
8356 nelberth 1723
				if(x<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+yf)>mouse.y){
1724
					if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y && (y+yf)>mouse.y){
1725
			 			$(elemento).css("cursor","nw-resize");
1726
			 		}else if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
1727
			 			$(elemento).css("cursor","ne-resize");
1728
			 		}else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
1729
			 			$(elemento).css("cursor","se-resize");
1730
			 		}else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y &&(y+yf)>mouse.y){
1731
			 			$(elemento).css("cursor","sw-resize");
1732
			 		}else{
1733
						$(elemento).css("cursor","move");
1734
					}
6682 nelberth 1735
			 	}else{
1736
			 		$(elemento).css("cursor","default");
1737
			 	}
1738
			}else if(texto_listo){
1739
				if(tx-10<mouse.x && tx-10+txf>mouse.x && ty-10<mouse.y && ty-10+tyf>mouse.y){
1740
			 		$(elemento).css("cursor","move");
1741
			 	}else if((txf+tx-10)<mouse.x &&(txf+tx-10+20)>mouse.x && (ty-10+tyf)<mouse.y && (ty-10+tyf+20)>mouse.y){
1742
			 		$(elemento).css("cursor","pointer");
1743
			 	}else{
1744
			 		$(elemento).css("cursor","default");
1745
			 	}
1746
			}
1747
			else{
1748
				$(elemento).css("cursor","default");
1749
			}
1750
		})
1751
		$(elemento).mousedown(function(e){
1752
			mouse = raton(this, e);
1753
			if(!recorte_listo){
8356 nelberth 1754
				if(x<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+yf)>mouse.y){
1755
 
1756
					 if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y && (y+yf)>mouse.y){
1757
						 t4 = true;
1758
					 }else if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
1759
						 t3 = true;
1760
					 }else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
1761
						 t1 = true;
1762
					 }else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y &&(y+yf)>mouse.y){
1763
						 t2 = true;
1764
					 }else{
1765
						 cli = true;
1766
					 }
1767
				  }
6682 nelberth 1768
			}else if(texto_listo){
1769
				if(tx-10<mouse.x && tx-10+txf>mouse.x && ty-10<mouse.y && ty-10+tyf>mouse.y){
1770
			 		tcli=true;
1771
			 	}else if((txf+tx-10)<mouse.x &&(txf+tx-10+20)>mouse.x && (ty-10+tyf)<mouse.y && (ty-10+tyf+20)>mouse.y){
1772
			 		rotar=true;
1773
			 	}
1774
			}
1775
 
1776
		 })
1777
 
11033 nelberth 1778
		 $('.editorNoticia').mousemove(function(e){
6682 nelberth 1779
		 	mouse = raton(this, e);
1780
		 	if(!recorte_listo){
1781
			 	if(cli){
1782
			 		if((mouse.y-(yf/2))>=0&&(mouse.y+(yf/2))<=alto){
1783
				 		y = (mouse.y-(yf/2));
1784
			 		}else{
1785
			 			if((mouse.y-(yf/2))<0){
1786
			 				y=0;
1787
			 			}
1788
			 			if((mouse.y+(yf/2))>alto){
1789
			 				y=alto-yf;
1790
			 			}
1791
			 		}
1792
			 		if((mouse.x-(xf/2))>=0&&(mouse.x+(xf/2))<=ancho){
1793
			 			x = (mouse.x-(xf/2));
1794
			 		}else{
1795
			 			if((mouse.x-(xf/2))<0){
1796
			 				x=0;
1797
			 			}
1798
			 			if((mouse.x+(xf/2))>ancho){
1799
			 				x=(ancho)-xf;
1800
			 			}
1801
			 		}
1802
			 	}
11038 nelberth 1803
				 if(blockCelda){
6682 nelberth 1804
			 	if(t4){
11032 nelberth 1805
					cal1=mouse.y-y;
1806
			 		cal2=cal1/recorte;
1807
					cal3=x+cal2;
1808
					if(cal2>50){
1809
						if(cal3<=ancho&&mouse.y<=alto){
1810
							yf=cal1;
1811
				 			xf=cal2;
1812
						}else if(cal3<=ancho&&mouse.y>alto){
1813
							yf=alto-y;
1814
							xf=yf/recorte
1815
						}else if(cal3>=ancho&&mouse.y<=alto){
1816
							xf=ancho-x;
1817
							yf=xf*recorte;
6682 nelberth 1818
						}
11032 nelberth 1819
				 	}
6682 nelberth 1820
			 	}
1821
			 	if(t3){
11032 nelberth 1822
					cal1=yf+(y-mouse.y);
1823
			 		cal2=cal1/recorte;
1824
					cal3=x+cal2;
1825
					if(cal2>50){
1826
						if(cal3<=ancho&&mouse.y>=0){
1827
							yf=cal1;
1828
				 			xf=cal2;
1829
							y=mouse.y;
1830
						}else if(cal3<=ancho&&mouse.y<0){
1831
							yf=yf+y;
1832
							xf=yf/recorte
1833
							y=0;
11038 nelberth 1834
						}else if(cal3>=ancho&&mouse.y>=0){
11032 nelberth 1835
							xf=ancho-x;
1836
							y=y+(yf-xf*recorte);
1837
							yf=xf*recorte;
1838
						}
1839
 
1840
				 	}
1841
 
6682 nelberth 1842
			 	}
1843
			 	if(t2){
11032 nelberth 1844
 
1845
					cal1=mouse.y-y;
11245 nelberth 1846
					cal2=cal1/recorte;
11032 nelberth 1847
					cal3=x+(yf-cal1)/recorte;cal2;
1848
					if(cal2>50){
1849
						if(cal3>=0&&mouse.y<=alto){
1850
							x=cal3;
1851
							yf=cal1;
11245 nelberth 1852
							xf=cal2;
1853
						}else if(cal3>0&&mouse.y>alto){
11032 nelberth 1854
							yf=alto-y;
1855
							x=x+(xf-yf/recorte);
1856
							xf=yf/recorte
11038 nelberth 1857
						}else if(cal3<0&&mouse.y<=alto){
11032 nelberth 1858
							xf=xf+x;
1859
							yf=xf*recorte;
1860
							x=0;
1861
						}
11245 nelberth 1862
					}
1863
 
1864
				}
1865
				if(t1){
11032 nelberth 1866
					cal0=y-mouse.y;
1867
					cal1=yf+cal0;
11245 nelberth 1868
					cal2=cal1/recorte;
11032 nelberth 1869
					cal3=x-cal0/recorte;
1870
					if(cal2>50){
1871
						if(cal3>=0&&mouse.y>=0){
1872
							yf=cal1;
11245 nelberth 1873
							xf=cal2;
1874
							x=cal3;
1875
							y=mouse.y;
1876
						}else if(cal3>0&&mouse.y<0){
11032 nelberth 1877
							yf=yf+y;
1878
							x=x+(xf-yf/recorte);
1879
							xf=yf/recorte
1880
							y=0;
11038 nelberth 1881
						}else if(cal3<0&&mouse.y>=0){
11032 nelberth 1882
							xf=xf+x;
1883
							y=y+(yf-xf*recorte);
1884
							yf=xf*recorte;
1885
							x=0;
1886
						}
11245 nelberth 1887
					}
1888
 
11032 nelberth 1889
				}
6682 nelberth 1890
				}else{
11032 nelberth 1891
				if(t4){
1892
 
1893
					cal1=mouse.y-y;
1894
					cal2=mouse.x-x;
1895
					if(cal1>50){
1896
						yf=mouse.y<=alto?cal1:alto-y;
1897
				 	}
1898
					if(cal2>50){
1899
						xf=mouse.x<=ancho?cal2:ancho-x;
1900
					}
6682 nelberth 1901
			 	}
11032 nelberth 1902
 
6682 nelberth 1903
			 	if(t3){
11032 nelberth 1904
					cal1=yf-(mouse.y-y);
1905
					cal2=mouse.x-x;
1906
					if(cal1>50){
1907
 
1908
						if(mouse.y>=0){
1909
							yf=cal1;
1910
							y=mouse.y;
1911
						}else{
1912
							yf=yf+y;
6682 nelberth 1913
							y=0;
1914
						}
11032 nelberth 1915
				 	}
1916
					if(cal2>50){
1917
						xf=mouse.x<=ancho?cal2:ancho-x;
1918
					}
6682 nelberth 1919
			 	}
1920
				/* Izquierda abajo */
1921
			 	if(t2){
11032 nelberth 1922
					cal1=mouse.y-y;
1923
					cal2=xf-(mouse.x-x);
1924
					if(cal1>50){
1925
						yf=yf=mouse.y<=alto?cal1:alto-y;
1926
					}
1927
					if(cal2>50){
1928
						if(mouse.x>=0){
1929
							xf=cal2;
1930
							x=mouse.x;
1931
						}else{
1932
							xf=xf+x;
1933
							x=0;
1934
						}
1935
					}
6682 nelberth 1936
			 	}
1937
				/* izquierda arriba */
1938
			 	if(t1){
11032 nelberth 1939
 
1940
					cal1=yf-(mouse.y-y);
1941
					cal2=xf-(mouse.x-x);
1942
					if(cal1>50){
1943
 
1944
						if(mouse.y>=0){
1945
							yf=cal1;
1946
							y=mouse.y;
1947
						}else{
1948
							yf=yf+y;
6682 nelberth 1949
							y=0;
1950
						}
11032 nelberth 1951
				 	}
1952
					if(cal2>50){
1953
						if(mouse.x>=0){
1954
							xf=cal2;
1955
							x=mouse.x;
1956
						}else{
1957
							xf=xf+x;
1958
							x=0;
1959
						}
1960
					}
1961
 
6682 nelberth 1962
			 	}
11032 nelberth 1963
				}
6682 nelberth 1964
 
1965
		 	actualizar();
1966
		 	}else if(texto_listo){
1967
		 		if(tcli){
1968
		 			tx=mouse.x-(txf/2)
1969
		 			ty=mouse.y-(tyf/2)
1970
		 		}else if(rotar){
1971
 
1972
		 		}
1973
 
1974
		 		actualizar2();
1975
		 	}
1976
		 })
11034 nelberth 1977
		 $('body').mouseup(function(e){
6682 nelberth 1978
		 	if(!recorte_listo){
1979
			 	cli=false;
1980
			 	t1=false;
1981
			 	t2=false;
1982
			 	t3=false;
1983
			 	t4=false;
1984
		 	}else if (texto_listo) {
1985
		 		tcli=false;
1986
		 	}
1987
		 })
1988
 
1989
 
1990
	}
1991
	/* Titulo */
1992
 
1993
var titulo_noticia, censor_titulo = true, numero_titulo=0;
1994
	$(document).on("keyup change", "#name", function(e){
1995
	console.log(numero_titulo)
1996
	titulo_noticia = $(this).val();
1997
	titulo_elemento= $(".titulo_topico");
1998
	if(titulo_noticia!=""){
1999
		if(censor_titulo){
2000
			titulo_elemento.html(titulo_noticia);
2001
			if(titulo_elemento.height()>38){
2002
				var titulo_noticia2 = "";
2003
				for(var i =0; i <titulo_noticia.length;i++){
2004
					titulo_noticia2 = titulo_noticia2 + titulo_noticia.split("")[i];
2005
					titulo_elemento.html(titulo_noticia2);
2006
					if(titulo_elemento.height()>38){
2007
						titulo_noticia2 = titulo_noticia2.slice(0,-5) + "...";
2008
						titulo_elemento.html(titulo_noticia2);
2009
						numero_titulo = titulo_noticia2.length;
2010
						censor_titulo=false;
2011
						break;
2012
					}
2013
 
2014
				}
2015
			}else{
2016
				numero_titulo=0;
2017
			}
2018
		}else{
2019
			if(numero_titulo+1>=titulo_noticia.length){
2020
				titulo_elemento.html(titulo_noticia);
2021
				censor_titulo=true;
2022
			}
2023
		}
2024
	}else{
2025
		titulo_elemento.html("LABEL_TITLE");
2026
		censor_titulo = true;
2027
	}
2028
})
2029
 
1 www 2030
});
2031
JS;
2032
$this->inlineScript()->captureEnd();
2033
?>
2034
 
15026 stevensc 2035
 
2036
 
1 www 2037
<!-- Content Header (Page header) -->
2038
<section class="content-header">
2039
	<div class="container-fluid">
15026 stevensc 2040
		<div class="row mb-2">
2041
			<div class="col-sm-12">
2042
				<h1>LABEL_CAPSULES</h1>
1 www 2043
			</div>
2044
		</div>
2045
	</div><!-- /.container-fluid -->
2046
</section>
2047
 
6704 nelberth 2048
<section class="content" id="content1">
1 www 2049
	<div class="container-fluid">
15026 stevensc 2050
		<div class="row">
2051
			<div class="col-12">
2052
				<div class="card">
1 www 2053
					<div class="card-header">
15026 stevensc 2054
						<?php
2055
						$form = $this->form;
2056
						$form->setAttributes([
2057
							'name'    => 'form-filter',
2058
							'id'      => 'form-filter',
2059
						]);
2060
 
2061
						$form->prepare();
2062
						echo $this->form()->openTag($form);
2063
						?>
2064
						<div class="form-group">
2065
							<?php
2066
							$element = $form->get('topic_uuid');
2067
 
2068
							$element->setAttributes(['class' => 'form-control']);
2069
							$element->setLabel('LABEL_TOPIC');
2070
							echo $this->formLabel($element);
2071
							echo $this->formSelect($element);
2072
							?>
2073
						</div>
1 www 2074
						<?php echo $this->form()->closeTag($form); ?>
15026 stevensc 2075
					</div>
1 www 2076
					<div class="card-body">
15026 stevensc 2077
						<table id="gridTable" class="table   table-hover">
2078
							<thead>
2079
								<tr>
2080
									<th>LABEL_NAME</th>
2081
									<th>LABEL_DETAILS</th>
2082
									<th>LABEL_IMAGES</th>
2083
									<th>LABEL_ACTIONS</th>
2084
								</tr>
2085
							</thead>
2086
							<tbody>
2087
							</tbody>
2088
						</table>
2089
					</div>
2090
					<div class="card-footer clearfix">
2091
						<div style="float:right;">
2092
							<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
2093
							<?php if ($allowAdd) : ?>
2094
								<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
1 www 2095
							<?php endif; ?>
2096
						</div>
15026 stevensc 2097
					</div>
2098
				</div>
2099
			</div>
2100
		</div>
2101
	</div>
2102
</section>
1 www 2103
 
2104
 
2105
<!-- The Modal -->
6694 nelberth 2106
<div id="modalCapsuleAdd" style='display:none'>
1 www 2107
 
6694 nelberth 2108
 
15026 stevensc 2109
	<!-- Modal Header -->
1 www 2110
 
15026 stevensc 2111
	<div class="d-flex justify-content-center tituloEditor">
2112
		<h4>LABEL_ADD_CAPSULE</h4>
6701 nelberth 2113
 
15026 stevensc 2114
	</div>
2115
	<!-- Modal body -->
2116
	<div class="grid-padre">
2117
		<?php
2118
		$form = $this->formAdd;
2119
		$form->setAttributes([
2120
			'method'  => 'post',
2121
			'action'  => '',
2122
			'name'    => 'form-capsule-add',
2123
			'id'      => 'form-capsule-add',
2124
		]);
1 www 2125
 
15026 stevensc 2126
		$form->prepare();
2127
		echo $this->form()->openTag($form);
2128
		?>
2129
		<div class="form-group grid-1-2">
2130
			<?php
2131
			$element = $form->get('name');
1 www 2132
 
15026 stevensc 2133
			$element->setAttributes(['class' => 'form-control']);
2134
			$element->setOptions(['label' => 'LABEL_NAME']);
2135
			echo $this->formLabel($element);
2136
			echo $this->formText($element);
2137
			?>
2138
		</div>
2139
		<div class="form-group grid-1-2">
2140
			<?php
2141
			$element = $form->get('description');
2142
			$element->setAttributes(['id' => 'description_add', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
2143
			$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
2144
			echo $this->formLabel($element);
2145
			echo $this->formTextArea($element);
2146
			?>
2147
		</div>
2148
		<div class="form-group grid-1-2">
2149
			<?php
2150
			$element = $form->get('order');
2151
			$element->setAttributes(['class' => 'form-control']);
2152
			$element->setOptions(['label' => 'LABEL_ORDER']);
2153
			echo $this->formLabel($element);
2154
			echo $this->formText($element);
2155
			?>
2156
		</div>
1 www 2157
 
15026 stevensc 2158
		<div class="form-group grid-1-2">
2159
			<?php
2160
			$element = $form->get('status');
2161
			$element->setAttributes(['class' => 'form-control']);
2162
			$element->setOptions(['label' => 'LABEL_STATUS']);
2163
			echo $this->formLabel($element);
2164
			echo $this->formSelect($element);
2165
			?>
2166
		</div>
2167
		<div class="form-group grid-1-2">
2168
			<?php
2169
			$element = $form->get('privacy');
2170
			$element->setAttributes(['class' => 'form-control']);
2171
			$element->setOptions(['label' => 'LABEL_PRIVACY']);
2172
			echo $this->formLabel($element);
2173
			echo $this->formSelect($element);
2174
			?>
2175
		</div>
2176
		<div class="form-group grid-1-2">
2177
			<?php
2178
			$element = $form->get('type');
2179
			$element->setAttributes(['class' => 'form-control']);
2180
			$element->setOptions(['label' => 'LABEL_TYPE']);
2181
			echo $this->formLabel($element);
2182
			echo $this->formSelect($element);
2183
			?>
2184
		</div>
2185
		<div class="form-group grid-1-2" id="form-row-cost">
2186
			<?php
2187
			$element = $form->get('cost');
2188
			$element->setAttributes(['class' => 'form-control']);
2189
			$element->setOptions(['label' => 'LABEL_COST']);
2190
			echo $this->formLabel($element);
2191
			echo $this->formText($element);
2192
			?>
2193
		</div>
1 www 2194
 
15026 stevensc 2195
		<?php
2196
		$element = $form->get('marketplace');
2197
		$element->setAttributes(['class' => 'marketplace']);
2198
		echo $this->formHidden($element);
2199
		?>
2200
		<?php
2201
		$element = $form->get('file');
2202
		$element->setAttributes(['class' => 'file']);
2203
		echo $this->formHidden($element);
2204
		?>
2205
		<div class="form-group grid-1-2 ">
2206
			<div class="imagen-contaner">
2207
				<label for="marketplaceImg">LABEL_IMAGE_MARKETPLACE</label>
2208
				<img class='marketplaceImg' src='' class="img img-responsive" style="width: 100px; height: auto"></img>
2209
			</div>
2210
		</div>
2211
		<h5 style="text-align:center " class="form-group grid-1-2" id='titleTypeImage'>LABEL_IMAGE_MARKETPLACE</h5>
2212
		<div class="contenido form-group " id="contenido"></div>
2213
 
2214
		<?php echo $this->form()->closeTag($form); ?>
2215
	</div>
2216
 
2217
 
2218
 
2219
</div>
2220
 
2221
 
1 www 2222
<!-- The Modal -->
15026 stevensc 2223
<div id="modalCapsuleEdit" style='display:none'>
1 www 2224
 
6976 nelberth 2225
 
15026 stevensc 2226
	<!-- Modal Header -->
1 www 2227
 
15026 stevensc 2228
	<div class="d-flex justify-content-center tituloEditor">
2229
		<h4>LABEL_EDIT_CAPSULE</h4>
6976 nelberth 2230
 
15026 stevensc 2231
	</div>
2232
	<!-- Modal body -->
2233
	<div class="grid-padre">
2234
		<?php
2235
		$form = $this->formEdit;
2236
		$form->setAttributes([
2237
			'method'    => 'post',
2238
			'name'      => 'form-capsule-edit',
2239
			'id'        => 'form-capsule-edit'
2240
		]);
1 www 2241
 
15026 stevensc 2242
		$form->prepare();
2243
		echo $this->form()->openTag($form);
2244
		?>
2245
		<div class="form-group grid-1-2">
2246
			<?php
2247
			$element = $form->get('name');
1 www 2248
 
15026 stevensc 2249
			$element->setAttributes(['class' => 'form-control']);
2250
			$element->setOptions(['label' => 'LABEL_NAME']);
2251
			echo $this->formLabel($element);
2252
			echo $this->formText($element);
2253
			?>
2254
		</div>
2255
		<div class="form-group grid-1-2">
2256
			<?php
2257
			$element = $form->get('description');
2258
			$element->setAttributes(['id' => 'description_edit', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
2259
			$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
2260
			echo $this->formLabel($element);
2261
			echo $this->formTextArea($element);
2262
			?>
2263
		</div>
2264
		<div class="form-group grid-1-2">
2265
			<?php
2266
			$element = $form->get('order');
2267
			$element->setAttributes(['class' => 'form-control']);
2268
			$element->setOptions(['label' => 'LABEL_ORDER']);
2269
			echo $this->formLabel($element);
2270
			echo $this->formText($element);
2271
			?>
2272
		</div>
1 www 2273
 
15026 stevensc 2274
		<div class="form-group grid-1-2">
2275
			<?php
2276
			$element = $form->get('status');
2277
			$element->setAttributes(['class' => 'form-control']);
2278
			$element->setOptions(['label' => 'LABEL_STATUS']);
2279
			echo $this->formLabel($element);
2280
			echo $this->formSelect($element);
2281
			?>
2282
		</div>
2283
		<div class="form-group grid-1-2">
2284
			<?php
2285
			$element = $form->get('privacy');
2286
			$element->setAttributes(['class' => 'form-control']);
2287
			$element->setOptions(['label' => 'LABEL_PRIVACY']);
2288
			echo $this->formLabel($element);
2289
			echo $this->formSelect($element);
2290
			?>
2291
		</div>
2292
		<div class="form-group grid-1-2">
2293
			<?php
2294
			$element = $form->get('type');
2295
			$element->setAttributes(['class' => 'form-control']);
2296
			$element->setOptions(['label' => 'LABEL_TYPE']);
2297
			echo $this->formLabel($element);
2298
			echo $this->formSelect($element);
2299
			?>
2300
		</div>
2301
		<div class="form-group grid-1-2" id="form-row-cost">
2302
			<?php
2303
			$element = $form->get('cost');
2304
			$element->setAttributes(['class' => 'form-control']);
2305
			$element->setOptions(['label' => 'LABEL_COST']);
2306
			echo $this->formLabel($element);
2307
			echo $this->formText($element);
2308
			?>
2309
		</div>
1 www 2310
 
15026 stevensc 2311
		<?php
2312
		$element = $form->get('marketplace');
2313
		$element->setAttributes(['class' => 'marketplace']);
2314
		echo $this->formHidden($element);
2315
		?>
2316
		<?php
2317
		$element = $form->get('file');
2318
		$element->setAttributes(['class' => 'file']);
2319
		echo $this->formHidden($element);
2320
		?>
2321
		<div class="form-group grid-1-2 ">
2322
			<div class="imagen-contaner">
2323
				<label for="marketplaceImg">LABEL_IMAGE_MARKETPLACE</label>
2324
				<img class='marketplaceImg' src='' class="img img-responsive" style="width: 100px; height: auto"></img>
2325
			</div>
2326
		</div>
2327
		<h5 style="text-align:center " class="form-group grid-1-2" id='titleTypeImage'>LABEL_IMAGE_MARKETPLACE</h5>
2328
		<div class="contenido form-group " id="contenido"></div>
2329
 
2330
		<?php echo $this->form()->closeTag($form); ?>
2331
	</div>
2332
 
2333
 
2334
</div>
2335
 
2336
 
2337
 
1 www 2338
<!-- The Modal -->
2339
<div class="modal" id="modalAppMarkeplate">
2340
	<div class="modal-dialog">
2341
		<div class="modal-content">
15026 stevensc 2342
			<!-- Modal Header -->
2343
			<div class="modal-header">
2344
				<h4 class="modal-title">LABEL_IMAGE_MARKETPLACE</h4>
2345
				<button type="button" class="close" data-dismiss="modal">&times;</button>
2346
			</div>
1 www 2347
 
15026 stevensc 2348
			<!-- Modal body -->
2349
			<div class="modal-body text-center">
2350
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-marketplace" />
2351
			</div>
2352
 
2353
			<!-- Modal footer -->
2354
			<div class="modal-footer">
2355
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
2356
			</div>
2357
		</div>
1 www 2358
	</div>
15026 stevensc 2359
</div>
1 www 2360
 
2361
 
2362
<!-- The Modal -->
2363
<div class="modal" id="modalImageApp">
2364
	<div class="modal-dialog ">
15026 stevensc 2365
		<div class="modal-content">
1 www 2366
 
15026 stevensc 2367
			<!-- Modal Header -->
2368
			<div class="modal-header">
2369
				<h4 class="modal-title">LABEL_IMAGE</h4>
2370
				<button type="button" class="close" data-dismiss="modal">&times;</button>
2371
			</div>
1 www 2372
 
15026 stevensc 2373
			<!-- Modal body -->
2374
			<div class="modal-body text-center">
1 www 2375
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-app" />
15026 stevensc 2376
			</div>
2377
 
2378
			<!-- Modal footer -->
2379
			<div class="modal-footer">
2380
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
2381
			</div>
2382
		</div>
1 www 2383
	</div>
15026 stevensc 2384
</div>
1 www 2385
 
2386
 
2387
 
15026 stevensc 2388
 
2389
 
2390
 
1 www 2391
<!-- The Modal -->
2392
<div class="modal" id="notificationUsersModal">
2393
	<div class="modal-dialog modal-xl">
15026 stevensc 2394
		<div class="modal-content">
1 www 2395
 
15026 stevensc 2396
			<!-- Modal Header -->
2397
			<div class="modal-header">
2398
				<h4 class="modal-title">LABEL_USERS</h4>
2399
				<button type="button" class="close" data-dismiss="modal">&times;</button>
2400
			</div>
1 www 2401
 
15026 stevensc 2402
			<!-- Modal body -->
2403
			<div class="modal-body">
2404
				<form>
2405
					<div class="form-group">
2406
						<label>LABEL_TOPIC</label>
2407
						<input type="text" readonly="readonly" id="table-users-topic" class="form-control">
2408
					</div>
2409
					<div class="form-group">
2410
						<label>LABEL_CAPSULE</label>
2411
						<input type="text" readonly="readonly" id="table-users-capsule" class="form-control">
2412
					</div>
2413
				</form>
2414
				<div style="height: 300px;overflow: scroll;">
2415
					<table id="gridTableUsers" style="width: 100%" class="table   table-hover">
2416
						<thead>
2417
							<tr>
2418
								<th>LABEL_FIRST_NAME</th>
2419
								<th>LABEL_LAST_NAME</th>
2420
								<th>LABEL_EMAIL</th>
2421
								<th>LABEL_DETAILS</th>
2422
							</tr>
2423
						</thead>
2424
						<tbody>
2425
						</tbody>
2426
					</table>
2427
				</div>
1 www 2428
 
15026 stevensc 2429
			</div>
1 www 2430
 
15026 stevensc 2431
			<!-- Modal footer -->
2432
			<div class="modal-footer">
2433
				<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
2434
			</div>
2435
 
2436
		</div>
1 www 2437
	</div>
15026 stevensc 2438
</div>