Proyectos de Subversion LeadersLinked - Backend

Rev

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

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