Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 7045 | Rev 8354 | 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];
6928 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"><span class="icon-plus fa fa-plus"></span>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
		})
820
 
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')
924
 
6824 nelberth 925
                selectorElementoEditor=campo.find('#contenido');
6682 nelberth 926
 
927
				if(image!=''){
6889 nelberth 928
					if(load){
6888 nelberth 929
						const getBase64FromUrl = async (url) => {
930
							const data = await fetch(url);
931
							const blob = await data.blob();
932
							return new Promise((resolve) => {
933
								const reader = new FileReader();
934
								reader.readAsDataURL(blob);
935
								reader.onloadend = function() {
936
								const base64data = reader.result;
937
								resolve(base64data);
938
								}
939
							});
940
						}
6682 nelberth 941
 
6888 nelberth 942
						getBase64FromUrl(image).then(function(e){
943
							selectorElementoName.trigger('change');
944
							$(".volver").css("display","block")
945
							$(".a1").addClass("paso");
946
							$(".titulo_pasos").html("LABEL_STEP_2");
947
							setTimeout(function(){
948
								recorte_listo=true;
949
								$(".fondo_oscuro").css("display","none");
6989 nelberth 950
								if(fileToggle){
7000 nelberth 951
									$("#boton_recortar").removeClass("recortar").text("LABEL_ATTACH_IMAGE").addClass("info_noticia");
6989 nelberth 952
									}else{
953
									$("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
954
								}
6888 nelberth 955
								$(".recortar10").removeClass("recortar");
956
								$(".canvas").removeClass("recortar");
957
								$(".b1").addClass("paso");
958
								$(".titulo_pasos").html("LABEL_STEP_3");
959
								if(texto!=""){
960
									seis=true;
961
									siete=true;
962
								}
963
								cinco=true;
964
								dos=true;
965
								cuatro=true;
966
								actualizar();
967
 
968
							},editorNoticia(e));
969
 
970
 
971
						})
6891 nelberth 972
						setTimeout(function(){
7000 nelberth 973
							$(".canvas_subir").html('<span class="icon-plus fa fa-spinner"></span> LABEL_LOADING...')
6891 nelberth 974
							selectorElementoName.trigger('change');
975
						},selectorElementoEditor.html(nuevoHtmlImagen));
6888 nelberth 976
					}else{
6682 nelberth 977
						selectorElementoName.trigger('change');
6891 nelberth 978
						setTimeout(function(){
6888 nelberth 979
							$(".volver").css("display","block")
980
							$(".a1").addClass("paso");
981
							$(".titulo_pasos").html("LABEL_STEP_2");
982
							setTimeout(function(){
6905 nelberth 983
								recorte_listo=true;
6888 nelberth 984
								$(".fondo_oscuro").css("display","none");
6987 nelberth 985
								if(fileToggle){
986
 
7000 nelberth 987
									$("#boton_recortar").removeClass("recortar").text("LABEL_ATTACH_IMAGE").addClass("info_noticia");
6988 nelberth 988
								}else{
6987 nelberth 989
									$("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
990
 
991
								}
6888 nelberth 992
								$(".recortar10").removeClass("recortar");
993
								$(".canvas").removeClass("recortar");
994
								$(".b1").addClass("paso");
995
								$(".titulo_pasos").html("LABEL_STEP_3");
996
								if(texto!=""){
997
									seis=true;
998
									siete=true;
999
								}
1000
								cinco=true;
1001
								dos=true;
1002
								cuatro=true;
1003
								actualizar();
6682 nelberth 1004
 
6888 nelberth 1005
							},editorNoticia(image));
6891 nelberth 1006
 
1007
 
1008
							selectorElementoName.trigger('change');
1009
						},selectorElementoEditor.html(nuevoHtmlImagen));
6888 nelberth 1010
					}
6891 nelberth 1011
 
6682 nelberth 1012
				}else{
1013
					setTimeout(function(){
1014
					    selectorElementoName.trigger('change');
1015
					},selectorElementoEditor.html(nuevoHtmlImagen));
1016
				}
1017
 
1018
		}
1019
 
1020
		$(window).on("scroll", function(){
1021
			console.log(scroll_altura)
1022
		if($(window).scrollTop()>scroll_altura){
1023
			$("#cuadro_noticias").addClass("fixed");
1024
		}else{
1025
			$("#cuadro_noticias").removeClass("fixed");
1026
		}
1027
	})
1028
 
1029
	$(document).on("dragover", "#imagen_noticia", function(e){
1030
		e.preventDefault();
1031
		e.stopPropagation();
1032
		$(this).css({"background":"rgba(0,0,0,.2)"})
1033
	})
1034
	$(document).on("drop", "#imagen_noticia", function(e){
1035
		e.preventDefault();
1036
		e.stopPropagation();
1037
		$(this).css("background", "none");
1038
		var archivo = e.originalEvent.dataTransfer.files;
1039
		var img=archivo[0];
1040
		if(img.type =="image/jpeg"||img.type =="image/png"){
1041
			$(".modificar").removeClass("animated");
1042
			var render = new FileReader();
1043
			render.readAsDataURL(img);
1044
			render.onload = function(e){
1045
				$(".volver").css("display","block")
1046
				$(".a1").addClass("paso");
1047
				$(".titulo_pasos").html("LABEL_STEP_2");
1048
				console.log(e.target.result)
1049
				editorNoticia(e.target.result)
1050
			}
1051
		}
1052
	})
1053
	$(document).on("dragover", "body", function(e){
1054
		e.preventDefault();
1055
		e.stopPropagation();
1056
	})
1057
	$(document).on("drop", "body", function(e){
1058
		e.preventDefault();
1059
		e.stopPropagation();
1060
	})
1061
 
1062
	var canvas='<div class="editorNoticia"><canvas id="editorNoticia">LABEL_NOT_SUPPORTED</canvas></div>';
1063
	$(document).on("mouseover", ".editorNoticia", function(){
1064
		$("body").css({"overflow": "hidden"});
1065
		$(".cuadro_noticias, .fixed_noticia,.tituloEditor,.grid-padre").css("margin-right", "17px")
1066
		$(".barra,.footer").css("padding-right","17px")
1067
 
1068
 
1069
	})
1070
	$(document).on("mouseover", "#editorNoticia", function(){
1071
		if(recorte_listo){
1072
			ocho=true;
1073
		}
1074
	})
1075
	$(document).on("mouseout", "#editorNoticia", function(){
1076
		if(recorte_listo){
1077
			ocho=false;
1078
			actualizar2()
1079
		}
1080
	})
1081
	$(document).on("mouseout", ".editorNoticia",function(){
1082
		$("body").css({"overflow": "auto"})
1083
		$(".cuadro_noticias, .fixed_noticia,.tituloEditor,.grid-padre").css("margin-right", "0px")
1084
		$(".barra,.footer").css("padding-right","0px")
1085
 
1086
	})
1087
	$(document).on('mousewheel', ".editorNoticia",function(e){
1088
		var ruedita = e.originalEvent.wheelDelta
1089
		if(ruedita>0){
1090
			scale = scale+(scale/10);
1091
			$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1092
		}else{
1093
			scale = scale-(scale/10);
1094
			$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1095
		}
1096
		$("#editorNoticia").css({"transform": "scale("+scale+")"});
1097
	})
1098
	$(document).on("click", ".as", function(e){
1099
		e.preventDefault();
1100
		 scale = $(this).data("scale");
1101
		 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
1102
		 $("#editorNoticia").css({"transform": "scale("+scale+")"});
1103
 
1104
	})
1105
	$(document).on("click", ".ps", function(e){
1106
		e.preventDefault();
1107
		$(".cantidades_scale").slideToggle(200).css("display", "block");
1108
	})
1109
	$(document).on("click", "#cerrar_filter_modal, .icon_filter", function(e){
1110
		e.preventDefault();
1111
		if(recorte_listo){
1112
		$(".contenido_filter").slideToggle(200).css("display", "block");
1113
		}
1114
	})
1115
	$(document).on("click", "#cerrar_text_modal, .icon_text", function(e){
1116
		e.preventDefault();
1117
		if(recorte_listo){
1118
			$(".contenido_text").slideToggle(200).css("display", "block");
1119
		}
1120
	})
1121
 
1122
	$(document).on("click", "#cerrar_cut_modal, .icon_cut", function(e){
1123
		e.preventDefault();
1124
		if(cortar){
1125
			$(".contenido_cut").slideToggle(200).css("display", "block");
1126
		}
1127
 
1128
	})
1129
	$(document).on("click", "#menos_scale", function(e){
1130
		e.preventDefault();
1131
		scale = scale-(scale/10);
1132
		 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
1133
		 $("#editorNoticia").css({"transform": "scale("+scale+")"});
1134
	})
1135
 
1136
	$(document).on("click", "#mas_scale", function(e){
1137
		e.preventDefault();
1138
		scale = scale+(scale/10);
1139
		 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
1140
		 $("#editorNoticia").css({"transform": "scale("+scale+")"});
1141
	})
1142
	$(document).on("click", "#noche", function(){
1143
		$(".oa").removeClass("oa")
1144
		filter( .5,1.3,1.31,1.33,1.38);
1145
		$(this).addClass("oa")
1146
	})
1147
	$(document).on("click", "#sa", function(){
1148
		$(".oa").removeClass("oa")
1149
		filter( .7,1.1,1.64,1.66,1.50);
1150
		$(this).addClass("oa")
1151
	})
1152
	$(document).on("click", "#crema", function(){
1153
		$(".oa").removeClass("oa")
1154
		filter( .75,1,1.66,1.60,1.51);
1155
		$(this).addClass("oa")
1156
	})
1157
	$(document).on("click", "#setenta", function(){
1158
		$(".oa").removeClass("oa")
1159
		filter( .8,.75,1.60,1.66,1.58);
1160
		$(this).addClass("oa")
1161
	})
1162
	$(document).on("click", "#orange", function(){
1163
		$(".oa").removeClass("oa")
1164
		filter( .8,1,1.6,1.45,1.49);
1165
		$(this).addClass("oa")
1166
	})
1167
	$(document).on("click", "#relieve", function(){
1168
		$(".oa").removeClass("oa")
1169
		filter( .7,1.2,1.60,1.66,1.58);
1170
		$(this).addClass("oa")
1171
	})
1172
	$(document).on("click", "#bosque", function(){
1173
		$(".oa").removeClass("oa")
1174
		filter( .85,.75,1.47,1.66,1.54);
1175
		$(this).addClass("oa")
1176
	})
1177
	$(document).on("click", "#desierto", function(){
1178
		$(".oa").removeClass("oa")
1179
		filter( .8,.9,1.66,1.43,1.28);
1180
		$(this).addClass("oa")
1181
	})
1182
	$(document).on("click", "#villa", function(){
1183
		$(".oa").removeClass("oa")
1184
		filter( .8,.8,1.71,1.64,1.58);
1185
		$(this).addClass("oa")
1186
	})
1187
	$(document).on("click", "#magia", function(){
1188
		$(".oa").removeClass("oa")
1189
		filter( .7,1.2,1.49,1.49,1.6);
1190
		$(this).addClass("oa")
1191
	})
1192
	$(document).on("click", "#luz", function(){
1193
		$(".oa").removeClass("oa")
1194
		filter( .9,.9,1.45,1.54,1.54);
1195
		$(this).addClass("oa")
1196
	})
1197
	$(document).on("click", "#retoque", function(){
1198
		$(".oa").removeClass("oa")
1199
		filter( .9,1.3,1,1,1);
1200
		$(this).addClass("oa")
1201
	})
1202
	$(document).on("click", "#saturacion", function(){
1203
		$(".oa").removeClass("oa")
1204
		filter( 1,1.5,1,1,1);
1205
		$(this).addClass("oa")
1206
	})
1207
	$(document).on("click", "#rosa", function(){
1208
		$(".oa").removeClass("oa")
1209
		filter( .8,1.2,1.24,.99,1);
1210
		$(this).addClass("oa")
1211
	})
1212
	$(document).on("click", "#historia", function(){
1213
		$(".oa").removeClass("oa")
1214
		filter( .9,1.1,1.33,1.19,.91);
1215
		$(this).addClass("oa")
1216
	})
1217
	$(document).on("click", "#encantador", function(){
1218
		$(".oa").removeClass("oa")
1219
		filter( .9,1.2,26,-12,0,2);
1220
		$(this).addClass("oa")
1221
	})
1222
	$(document).on("click", "#emocion", function(){
1223
		$(".oa").removeClass("oa")
1224
		filter( 1.1,1.4,40,12,-6,2);
1225
		$(this).addClass("oa")
1226
	})
1227
	$(document).on("click", "#beige", function(){
1228
		$(".oa").removeClass("oa")
1229
		filter( .9,1.32,56,47,17,2);
1230
		$(this).addClass("oa")
1231
	})
1232
	$(document).on("click", "#fine", function(){
1233
		$(".oa").removeClass("oa")
1234
		filter( .87,1.19,55,37,23,2);
1235
		$(this).addClass("oa")
1236
	})
1237
	$(document).on("click", "#lord", function(){
1238
		$(".oa").removeClass("oa")
1239
		filter( 1.2,.9,67,13,-23,2);
1240
		$(this).addClass("oa")
1241
	})
1242
	$(document).on("click", "#70", function(){
1243
		$(".oa").removeClass("oa")
1244
		filter( 1.2,1.2,35,7,18,2);
1245
		$(this).addClass("oa")
1246
	})
1247
	$(document).on("click", "#arbol", function(){
1248
		$(".oa").removeClass("oa")
1249
		filter(.92,1.23,-11,11,11,2);
1250
		$(this).addClass("oa")
1251
	})
1252
	$(document).on("click", "#verano", function(){
1253
		$(".oa").removeClass("oa")
1254
		filter( 1,1.4,-3,-1,-12,2);
1255
		$(this).addClass("oa")
1256
	})
1257
	$(document).on("click", "#cf", function(){
1258
		$(".oa").removeClass("oa")
1259
		filter( .85,1.26,-15,2,-1,2);
1260
		$(this).addClass("oa")
1261
	})
1262
	$(document).on("click", "#angeles", function(){
1263
		$(".oa").removeClass("oa")
1264
		filter( 1,1.4,5,12,1,2);
1265
		$(this).addClass("oa")
1266
	})
1267
	$(document).on("click", "#caliente", function(){
1268
		$(".oa").removeClass("oa")
1269
		filter( .9,1.2,43,-17,-55,2);
1270
		$(this).addClass("oa")
1271
	})
1272
	$(document).on("click", "#otono", function(){
1273
		$(".oa").removeClass("oa")
1274
		filter( 1,1.29,29,26,17,2);
1275
		$(this).addClass("oa")
1276
	})
1277
	$(document).on("click", "#marzo", function(){
1278
		$(".oa").removeClass("oa")
1279
		filter( .85,1.3,43,25,-11,2);
1280
		$(this).addClass("oa")
1281
	})
1282
	$(document).on("click", "#pera", function(){
1283
		$(".oa").removeClass("oa")
1284
		filter( .8,1.25,31,41,12,2);
1285
		$(this).addClass("oa")
1286
	})
1287
	$(document).on("click", "#comun", function(){
1288
		$(".oa").removeClass("oa")
1289
		filter( 1,1.36,4,5,1,2);
1290
		$(this).addClass("oa")
1291
	})
1292
	$(document).on("click", "#oro", function(){
1293
		$(".oa").removeClass("oa")
1294
		filter( .9,1.3,37,-25,1,2);
1295
		$(this).addClass("oa")
1296
	})
1297
	$(document).on("click", "#gotico", function(){
1298
		$(".oa").removeClass("oa")
1299
		filter( 1.1,1.3,-47,-42,-30,2);
1300
		$(this).addClass("oa")
1301
	})
1302
	$(document).on("click", "#forestal", function(){
1303
		$(".oa").removeClass("oa")
1304
		filter( 1,1.4,-5,42,11,2);
1305
		$(this).addClass("oa")
1306
	})
1307
	$(document).on("click", "#luna", function(){
1308
		$(".oa").removeClass("oa")
1309
		filter( .9,1.2,-5,-7,4,2);
1310
		$(this).addClass("oa")
1311
	})
1312
	$(document).on("click", "#fiesta", function(){
1313
		$(".oa").removeClass("oa")
1314
		filter( 1.1,1.3,-1,-1,26,2);
1315
		$(this).addClass("oa")
1316
	})
1317
	$(document).on("click", "#gris", function(){
1318
		$(".oa").removeClass("oa")
1319
		filtergris(1,1)
1320
		$(this).addClass("oa")
1321
	})
1322
	$(document).on("click", "#lhs", function(){
1323
		$(".oa").removeClass("oa")
1324
		filtergris(.8,1.5);
1325
		$(this).addClass("oa")
1326
	})
1327
	$(document).on("click", "#normal", function(){
1328
		$(".oa").removeClass("oa")
1329
		$(this).addClass("oa")
1330
		filter();
1331
	})
1332
	var texto_listo=false,siete=false;
1333
	var texto;
1334
	$(document).on("keyup", "#texto_input", function(e){
1335
		e.preventDefault();
1336
		texto = $(this).val();
1337
		if(texto_actualizar){
1338
			siete=true;
1339
		}
1340
		if(texto!=""){
1341
			texto_actualizar=true;
1342
			actualizar2();
1343
		}else{
1344
			actualizar2();
1345
		}
1346
 
1347
	})
1348
	var color="#ffffff";
1349
	$(document).on("change", "#color", function(){
1350
    	color=$(this).val();
1351
    	seis=true;
1352
    	actualizar2();
1353
    })
1354
    var size=48;
1355
    $(document).on("keyup change", "#font-size", function(){
1356
    	size=$(this).val();
1357
    	size = parseInt(size);
1358
    	seis=true;
1359
    	siete=true;
1360
    	actualizar2();
1361
    })
1362
    var negritas=false, bold="";
1363
    $(document).on("click", "#negritas", function(e){
1364
    	e.preventDefault();
1365
    	if(!negritas){
1366
    		bold="bold";
1367
    		$(this).addClass("fa");
1368
    		seis=true;
1369
    		siete=true;
1370
    		actualizar2();
1371
    		negritas=true;
1372
    	}else{
1373
    		bold="";
1374
    		$(this).removeClass("fa");
1375
    		seis=true;
1376
    		siete=true;
1377
    		actualizar2();
1378
    		negritas=false;
1379
    	}
1380
    })
1381
    var italic=false, ita="";
1382
     $(document).on("click", "#italic", function(e){
1383
    	e.preventDefault();
1384
    	if(!italic){
1385
    		ita="italic";
1386
    		$(this).addClass("fa");
1387
    		seis=true;
1388
    		siete=true;
1389
    		actualizar2();
1390
    		italic=true;
1391
    	}else{
1392
    		ita="";
1393
    		$(this).removeClass("fa");
1394
    		seis=true;
1395
    		siete=true;
1396
    		actualizar2();
1397
    		italic=false;
1398
    	}
1399
    })
1400
     var fontfamily="Arial";
1401
     $(document).on("click", ".fs", function(e){
1402
    	e.preventDefault();
1403
    	$(".at").removeClass("at");
1404
    	$(this).addClass("at");
1405
    	fontfamily= $(this).text();
1406
    	seis=true;
1407
    	siete=true;
1408
    	actualizar2();
1409
 
1410
    })
1411
     var shadow = true, nueve=true;
1412
     $(document).on("click","#shadow", function(e){
1413
     	e.preventDefault();
1414
     	if(shadow){
1415
     		$(this).removeClass("fa");
1416
     		seis=true;
1417
     		nueve=false;
1418
     		actualizar2();
1419
     		shadow=false;
1420
     	}else{
1421
     		$(this).addClass("fa");
1422
     		seis=true;
1423
     		nueve=true;
1424
     		actualizar2();
1425
     		shadow=true;
1426
     	}
1427
 
1428
     })
1429
     var rectangulo=false, diez=false, colorrect="#000000";
1430
     $(document).on("click", "#rectangulo", function(e){
1431
     	e.preventDefault();
1432
     	if(!rectangulo){
1433
     		$(this).addClass("fa");
1434
     		diez=true;
1435
     		actualizar2();
1436
     		rectangulo=true;
1437
     	}else{
1438
     		$(this).removeClass("fa");
1439
     		diez=false;
1440
     		actualizar2();
1441
     		rectangulo=false;
1442
     	}
1443
 
1444
     })
1445
     var r=0,g=0,b=0;
1446
    $(document).on("change", "#colorrect", function(){
1447
    	colorrect=$(this).val();
1448
    	r=parseInt(colorrect.slice(1,3),16);
1449
    	g=parseInt(colorrect.slice(3,5),16);
1450
    	b=parseInt(colorrect.slice(5,7),16);
1451
    	seis=true;
1452
    	actualizar2();
1453
    })
1454
    var a=1;
1455
 
1456
    $(document).on("keyup change", "#opacidad", function(){
1457
    	a=$(this).val();
1458
    	a=a/100;
1459
    	seis=true;
1460
    	actualizar2();
1461
    })
1462
	var imaNoti = new Image();
1463
	function filter(brillo=1, contraste=1, rojo=1, verde=1, azul=1, valor=1){
1464
		cuatro=false;
1465
		restaurar(brillo, contraste);
1466
		datos=imagenOriginal.data;
1467
		if(valor==2){
1468
			for (var i =  0; i <datos.length; i+=4) {
1469
				datos[i]=datos[i]+rojo;
1470
				datos[i+1]=datos[i+1]+verde;
1471
				datos[i+2]=datos[i+2]+azul;
1472
			}
1473
		}else{
1474
			for (var i =  0; i <datos.length; i+=4) {
1475
				datos[i]=datos[i]*rojo;
1476
				datos[i+1]=datos[i+1]*verde;
1477
				datos[i+2]=datos[i+2]*azul
1478
			}
1479
		}
1480
		editor.putImageData(imagenOriginal,0,0)
1481
		var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
1482
	    imaNoti.src = imagenNoticia;
1483
		actualizar2();
1484
	}
1485
	function filtergris(brillo=1, contraste=1){
1486
		cuatro=false;
1487
		restaurar(brillo, contraste);
1488
		datos=imagenOriginal.data;
1489
		var auxiliar;
1490
		for (var i =  0; i <datos.length; i+=4) {
1491
			auxiliar = 0.34 * datos[i] + 0.5 *datos[i+1] + 0.16 * datos[i+2];
1492
			datos[i]=auxiliar;
1493
			datos[i+1]=auxiliar;
1494
			datos[i+2]=auxiliar;
1495
		}
1496
 
1497
		editor.putImageData(imagenOriginal,0,0)
1498
		var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
1499
	    imaNoti.src = imagenNoticia;
1500
		actualizar2();
1501
	}
1502
	function restaurar(brillo = 1, contraste=1){
1503
		editor.filter = "none"
1504
		editor.filter = 'contrast('+contraste+') brightness('+brillo+') saturate(1) sepia(0)';
1505
		editor.fillStyle="rgba(255,255,255,1)"
1506
		editor.fillRect(0,0,ancho,alto);
1507
		editor.fillStyle=""+color+"";
1508
		var pxf=0,pyf=0;
1509
			if(xf>=(yf/recorte)){
1510
				pxf=xf/ancho;
1511
				pyf=yf/pxf;
1512
				py=(alto/2)-(pyf/2);
1513
				editor.drawImage(imagen,x,y,xf,yf,0,py,ancho,pyf);
1514
			}else{
1515
				pyf=yf/alto;
1516
				pxf=xf/pyf;
1517
				px=(ancho/2)-(pxf/2);
1518
				editor.drawImage(imagen,x,y,xf,yf,px,0,pxf,alto);
1519
			}
1520
		imagenOriginal = editor.getImageData(0,0,ancho,alto)
1521
	}
1522
	var ocho=false;
1523
	function actualizar2(){
1524
		if(recorte_listo){
1525
		if(cuatro){
1526
			imagenOriginal = editor.getImageData(0,0,ancho,alto)
1527
			var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
1528
	    	imaNoti.src = imagenNoticia;
1529
	    	cuatro=false;
1530
		}
1531
		editor.filter = "none"
1532
		$(imaNoti).ready(function(e){
6926 nelberth 1533
			noticia.drawImage(imaNoti,0,0,pw,ph);
6682 nelberth 1534
			editor.drawImage(imaNoti,0,0,ancho,alto)
1535
			if(texto_actualizar){
1536
				if(texto!=""){
1537
					if(seis){
1538
						ancho_imaNoti = imaNoti.width;
1539
 
6926 nelberth 1540
						scale_noticia = -(((ancho_imaNoti-pw)/ancho_imaNoti)-1);
6682 nelberth 1541
						editor.fillStyle=""+color+"";
1542
						editor.strokeStyle="rgb(255,255,255)";
1543
						if(nueve){
1544
							editor.shadowColor="rgba(0,0,0,.5)";
1545
							editor.shadowOffsetX=6;
1546
							editor.shadowOffsetY=6;
1547
							editor.shadowBlur=6;
1548
							noticia.shadowColor="rgba(0,0,0,.5)";
1549
							noticia.shadowOffsetX=6*scale_noticia;
1550
							noticia.shadowOffsetY=6*scale_noticia;
1551
							noticia.shadowBlur=6*scale_noticia;
1552
						}else{
1553
							editor.shadowColor="rgba(0,0,0,0)";
1554
							noticia.shadowColor="rgba(0,0,0,0)";
1555
						}
1556
						editor.font=""+ita+" "+bold+" "+size+"px "+fontfamily+"";
1557
						editor.textAlign="start";
1558
						editor.textBaseline="top";
1559
 
1560
						var sizeNoticia = size*scale_noticia;
1561
						noticia.fillStyle=""+color+"";
1562
						noticia.font=""+ita+" "+bold+" "+sizeNoticia+"px "+fontfamily+"";
1563
						noticia.textAlign="start";
1564
						noticia.textBaseline="top";
1565
						seis=false;
1566
					}
1567
					if(siete){
1568
						dimencionesTexto = editor.measureText(texto);
1569
						txf=dimencionesTexto.width+20;
1570
						tyf= (20+size);
1571
						siete=false;
1572
					}
1573
					if(cinco){
1574
						dimencionesTexto = editor.measureText(texto);
1575
						if(xf>=(yf/recorte)){
1576
							tx=(xf/2)-(dimencionesTexto.width/2);
1577
							ty=(xf*recorte/2)-(size/2);
1578
						}else{
1579
							tx=(yf/recorte/2)-(dimencionesTexto.width/2);
1580
							ty=(yf/2)-(size/2);
1581
						}
1582
 
1583
						txf=dimencionesTexto.width+20;
1584
						tyf= size+20;
1585
						cinco=false;
1586
					}
1587
					if(diez){
1588
						editor.fillStyle="rgba("+r+","+g+","+b+","+a+")";
1589
						noticia.fillStyle="rgba("+r+","+g+","+b+","+a+")";
1590
						editor.fillRect(tx-10,ty-10,txf,tyf);
1591
						noticia.fillRect(((tx-10)*scale_noticia),((ty-10)*scale_noticia),txf*scale_noticia,tyf*scale_noticia);
1592
						editor.fillStyle=""+color+"";
1593
						noticia.fillStyle=""+color+"";
1594
 
1595
					}
1596
					editor.fillText(texto,tx,ty);
1597
					noticia.fillText(texto,(tx*scale_noticia),ty*scale_noticia);
1598
					if(ocho){
1599
						editor.strokeRect(tx-10,ty-10,txf,tyf)
1600
						editor.arc(tx+txf,ty+tyf,10,0,Math.PI*2,false);
1601
						editor.fill();
1602
						editor.beginPath();
1603
					}
1604
					texto_listo=true;
1605
				}
1606
			}
1607
		})
1608
 
1609
	}
1610
	}
1611
	function actualizar(){
6962 nelberth 1612
 
6961 nelberth 1613
			$(imagen).ready(function(e){
1614
 
6682 nelberth 1615
				if(uno){
6962 nelberth 1616
					elemento2.height=ph;
6964 nelberth 1617
					elemento2.width=pw;
6682 nelberth 1618
					ancho=imagen.width, alto = imagen.height;
1619
					elemento.width = ancho;
1620
					elemento.height = alto;
6956 nelberth 1621
 
6682 nelberth 1622
					$(".scale").css("display","flex");
1623
					mitadX=ancho/2;
1624
					mitadY=alto/2;
1625
					x=mitadX-xf/2;
1626
					y=mitadY-yf/2;
1627
					if(ancho<=alto){
1628
					 scale = -(((alto-450)/alto)-1);
1629
 
1630
					}else{
1631
					 scale = -(((ancho-500)/ancho)-1);
1632
					}
1633
					$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1634
					$("#ancho").html(ancho+"px");
1635
					$("#alto").html(alto+"px");
1636
					uno=false;
1637
				}
1638
				if(dos){
1639
 
1640
					if(xf>=(yf/recorte)){
1641
						alto=xf*recorte;
1642
						ancho=xf;
1643
					}else{
1644
						ancho=yf/recorte;
1645
						alto=yf;
1646
 
1647
					}
1648
					elemento.width = ancho;
1649
					elemento.height = alto;
6963 nelberth 1650
					elemento2.height=ph;
1651
					elemento2.width=pw;
6682 nelberth 1652
					if(xf<=yf){
1653
					 scale = -(((yf-450)/yf)-1);
1654
 
1655
					}else{
1656
					 scale = -(((xf-500)/xf)-1);
1657
					}
1658
 
1659
					$("#porciento_scale").html((scale*100).toFixed(2)+"%")
1660
					$("#ancho").html(Math.round(xf)+"px");
1661
					$("#alto").html(Math.round(yf)+"px");
1662
					dos=false;
1663
				}
1664
 
1665
					var pxf=0,pyf=0;
1666
					noticia.fillStyle="rgba(255,255,255,1)"
6926 nelberth 1667
					noticia.fillRect(0,0,pw,ph);
6682 nelberth 1668
				if(xf>=(yf/recorte)){
6926 nelberth 1669
					pxf=xf/pw;
6682 nelberth 1670
					pyf=yf/pxf;
6926 nelberth 1671
					py=(ph/2)-(pyf/2);
1672
					noticia.drawImage(imagen,x,y,xf,yf,0,py,pw,pyf);
6682 nelberth 1673
				}else{
6926 nelberth 1674
					pyf=yf/ph;
6682 nelberth 1675
					pxf=xf/pyf;
6926 nelberth 1676
					px=(pw/2)-(pxf/2);
1677
					noticia.drawImage(imagen,x,y,xf,yf,px,0,pxf,ph);
6682 nelberth 1678
				}
1679
 
1680
				$("#editorNoticia").css({"transform": "scale("+scale+")"});
1681
				if(!recorte_listo){
1682
					editor.drawImage(imagen,0,0,ancho,alto);
1683
					editor.fillStyle="rgba(0,0,0,.2)"
1684
					editor.fillRect(0,0,ancho,alto);
1685
					editor.fillStyle="rgba(255,255,255,.1)"
1686
					editor.fillRect(x,y,xf,yf);
1687
					editor.fillStyle="rgba(255,255,255,.5)"
1688
					editor.fillRect(x,y,16,16);
1689
					editor.fillRect((x+xf)-16,y,16,16);
1690
					editor.fillRect(x,y+yf-16,16,16);
1691
					editor.fillRect(x+xf-16,yf+y-16,16,16);
1692
					esta=true;
1693
				}else{
1694
					var pxf=0,pyf=0;
1695
 
1696
					editor.fillStyle="rgba(255,255,255,1)"
1697
					editor.fillRect(0,0,ancho,alto);
1698
					if(xf>=(yf/recorte)){
1699
						pxf=xf/ancho;
1700
						pyf=yf/pxf;
1701
						py=(alto/2)-(pyf/2);
1702
						editor.drawImage(imagen,x,y,xf,yf,0,py,ancho,pyf);
1703
					}else{
1704
						pyf=yf/alto;
1705
						pxf=xf/pyf;
1706
						px=(ancho/2)-(pxf/2);
1707
						editor.drawImage(imagen,x,y,xf,yf,px,0,pxf,alto);
1708
				}
1709
 
1710
				}
1711
			})
1712
		}
6966 nelberth 1713
	var imagenOriginal
6956 nelberth 1714
	var x,y,xf=pw,yf =ph, elemento,elemento2,editor,centro, total,scale,dimencionesTexto,ancho_imaNoti,
6682 nelberth 1715
	recorte_listo=false,alto,ancho,tx,ty,txf,tyf,cuatro=true,texto_actualizar=false,cinco=true,seis=true,cuatro;
6970 nelberth 1716
	var  mitadY,mitadX, uno=true,dos=false, recorte=ph/pw, imagen_noticias, scale_noticia, tres=true,rotar=false, cortar=false;;
6682 nelberth 1717
	var translateX;
1718
 
1719
	$(document).on("click", ".recortar10", function(e){
1720
 
1721
		e.preventDefault();
1722
		recorte_listo=false;
1723
		uno=true;
1724
		$(".fondo_oscuro").css("display","block");
7000 nelberth 1725
		$("#boton_recortar").addClass("recortar").text("LABEL_CUT").removeClass("info_noticia");
1726
		$("#boton_recortar3").addClass("recortar").text("LABEL_CUT").removeClass("info_noticia3");
6682 nelberth 1727
		$(".contenido_text").css("display", "none");
1728
		$(".contenido_filter").css("display", "none");
1729
		$(".recortar10").addClass("recortar");
1730
		$(".canvas").addClass("recortar")
1731
		$(".oa").removeClass("oa");
1732
		$("#normal").addClass("oa");
1733
		$(".b1").removeClass("paso");
1734
		$(".titulo_pasos").html("LABEL_STEP_2");
1735
		window.clearInterval(actualizar2);
1736
		actualizar();
1737
 
1738
	})
1739
 
1740
 
1741
	blockCelda=true;
1742
	$(document).on("click", "#blockCelda", function(e){
1743
		e.preventDefault();
1744
		if(blockCelda){
1745
			$(this).html('<span class="fa fa-unlock"></span>')
1746
 
1747
			blockCelda=false;
1748
		}else{
1749
			$(this).html('<span class="fa fa-lock"></span>')
1750
			blockCelda=true;
1751
		}
1752
		t4=true;
1753
 
1754
	})
1755
	var imagen
1756
	function editorNoticia(img){
1757
		 cortar=true;
1758
		imagen= new Image();
1759
		$(".canvas").html(canvas);
1760
		elemento = document.getElementById("editorNoticia");
1761
		editor = elemento.getContext("2d");
1762
		elemento2 = document.getElementById("imagen_noticias");
1763
		noticia = elemento2.getContext("2d");
1764
 
1765
		$(document).on("click", ".boton_marino.recortar",function(e){
1766
			e.preventDefault();
1767
			recorte_listo=true;
1768
			$(".fondo_oscuro").css("display","none");
6863 nelberth 1769
			if(fileToggle){
7000 nelberth 1770
				$("#boton_recortar").removeClass("recortar").text("LABEL_ATTACH_IMAGE").addClass("info_noticia");
6863 nelberth 1771
			}else{
1772
				$("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
1773
			}
6682 nelberth 1774
			$(".recortar10").removeClass("recortar");
1775
			$(".canvas").removeClass("recortar");
1776
			$(".b1").addClass("paso");
1777
			$(".titulo_pasos").html("LABEL_STEP_3");
1778
			if(texto!=""){
1779
				seis=true;
1780
				siete=true;
1781
			}
1782
			cinco=true;
1783
			dos=true;
1784
			cuatro=true;
1785
			actualizar();
1786
		})
1787
 
1788
		var cli = false, t1= false, t2=false,t3=false,t4=false,tcli=false;
1789
		var mouse =[];
1790
 
1791
 
1792
		function raton(elemento, e){
1793
			return {
1794
				x:((e.pageX - elemento.offsetLeft - ((ancho/2)-((ancho*scale)/2)))/scale),
1795
				y:((e.pageY - elemento.offsetTop - ((alto/2)-((alto*scale)/2)))/scale)
1796
			}
1797
		}
1798
 
1799
		imagen.src=img;
1800
		$(".recortar10").addClass("recortar");
1801
		$("#boton_recortar").removeClass("boton_normal").addClass("recortar boton_marino").text("LABEL_CUT")
1802
		actualizar();
1803
 
1804
		$(elemento).mousemove(function(e){
1805
			mouse = raton(this, e);
1806
			//console.log("raton x: "+mouse.x+ " raton Y: " +mouse.y+ " tx: "+tx+" ty: "+ty+" txf:"+(txf+tx)+" tyf:"+(tyf+ty) )
1807
			if(!recorte_listo){
1808
				if(x+16<mouse.x &&(xf+x-16)>mouse.x && y+16<mouse.y && (y+yf-16)>mouse.y){
1809
			 		$(elemento).css("cursor","move");
1810
			 	}else if((xf+x-16)<mouse.x &&(xf+x)>mouse.x && (y+yf-16)<mouse.y && (y+yf)>mouse.y){
1811
			 		$(elemento).css("cursor","nw-resize");
1812
			 	}else if((xf+x-16)<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+16)>mouse.y){
1813
			 		$(elemento).css("cursor","ne-resize");
1814
			 	}else if(x<mouse.x &&(16+x)>mouse.x && y<mouse.y && (y+16)>mouse.y){
1815
			 		$(elemento).css("cursor","se-resize");
1816
			 	}else if(x<mouse.x &&(16+x)>mouse.x && (y+yf-16)<mouse.y &&(y+yf)>mouse.y){
1817
			 		$(elemento).css("cursor","sw-resize");
1818
			 	}else{
1819
			 		$(elemento).css("cursor","default");
1820
			 	}
1821
			}else if(texto_listo){
1822
				if(tx-10<mouse.x && tx-10+txf>mouse.x && ty-10<mouse.y && ty-10+tyf>mouse.y){
1823
			 		$(elemento).css("cursor","move");
1824
			 	}else if((txf+tx-10)<mouse.x &&(txf+tx-10+20)>mouse.x && (ty-10+tyf)<mouse.y && (ty-10+tyf+20)>mouse.y){
1825
			 		$(elemento).css("cursor","pointer");
1826
			 	}else{
1827
			 		$(elemento).css("cursor","default");
1828
			 	}
1829
			}
1830
			else{
1831
				$(elemento).css("cursor","default");
1832
			}
1833
		})
1834
		$(elemento).mousedown(function(e){
1835
			mouse = raton(this, e);
1836
			if(!recorte_listo){
1837
				if(x+16<mouse.x &&(xf+x-16)>mouse.x && y+16<mouse.y && (y+yf-16)>mouse.y){
1838
			 		cli = true;
1839
			 	}
1840
			 	if((xf+x-16)<mouse.x &&(xf+x)>mouse.x && (y+yf-16)<mouse.y && (y+yf)>mouse.y){
1841
			 		t4 = true;
1842
			 	}
1843
				if((xf+x-16)<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+16)>mouse.y){
1844
			 		t3 = true;
1845
			 	}
1846
			 	if(x<mouse.x &&(16+x)>mouse.x && y<mouse.y && (y+16)>mouse.y){
1847
			 		t1 = true;
1848
			 	}
1849
			 	if(x<mouse.x &&(16+x)>mouse.x && (y+yf-16)<mouse.y &&(y+yf)>mouse.y){
1850
			 		t2 = true;
1851
			 	}
1852
			}else if(texto_listo){
1853
				if(tx-10<mouse.x && tx-10+txf>mouse.x && ty-10<mouse.y && ty-10+tyf>mouse.y){
1854
			 		tcli=true;
1855
			 	}else if((txf+tx-10)<mouse.x &&(txf+tx-10+20)>mouse.x && (ty-10+tyf)<mouse.y && (ty-10+tyf+20)>mouse.y){
1856
			 		rotar=true;
1857
			 	}
1858
			}
1859
 
1860
		 })
1861
 
1862
		 $(elemento).mousemove(function(e){
1863
		 	mouse = raton(this, e);
1864
		 	if(!recorte_listo){
1865
			 	if(cli){
1866
			 		if((mouse.y-(yf/2))>=0&&(mouse.y+(yf/2))<=alto){
1867
				 		y = (mouse.y-(yf/2));
1868
			 		}else{
1869
			 			if((mouse.y-(yf/2))<0){
1870
			 				y=0;
1871
			 			}
1872
			 			if((mouse.y+(yf/2))>alto){
1873
			 				y=alto-yf;
1874
			 			}
1875
			 		}
1876
			 		if((mouse.x-(xf/2))>=0&&(mouse.x+(xf/2))<=ancho){
1877
			 			x = (mouse.x-(xf/2));
1878
			 		}else{
1879
			 			if((mouse.x-(xf/2))<0){
1880
			 				x=0;
1881
			 			}
1882
			 			if((mouse.x+(xf/2))>ancho){
1883
			 				x=(ancho)-xf;
1884
			 			}
1885
			 		}
1886
			 	}
1887
				if(blockCelda){
1888
			 	if(t4){
1889
			 		if(mouse.y<(alto-10)&&(x+xf)<=(ancho)){
1890
				 		if(Math.round(xf)>=50){
1891
							if(((mouse.y-y)/recorte)>50){
1892
				 				yf=mouse.y-y;
1893
				 				xf=(yf/recorte);
1894
				 			}
1895
						}
1896
			 		}else{
1897
			 			if(mouse.y>=(alto-10)){
1898
			 				yf=alto-y;
1899
				 			xf=(yf/recorte);
1900
				 			t4=false;
1901
			 			}
1902
			 			if(x+xf>(ancho)){
1903
			 				xf=(ancho)-x;
1904
				 			yf=(xf*recorte);
1905
				 			t4=false;
1906
			 			}
1907
			 		}
1908
			 	}
1909
			 	if(t3){
1910
			 		if(mouse.y>0&&(x+xf)<=(ancho)){
1911
				 		if(Math.round(xf)>=50){
1912
							if(((yf+(y-mouse.y))/recorte)>50){
1913
					 			yf=yf+(y-mouse.y);
1914
					 			xf=(yf/recorte);
1915
					 			y=mouse.y;
1916
				 			}
1917
				 		}
1918
 
1919
			 		}else{
1920
			 			if(mouse.y<=0) {
1921
			 				yf=yf+(y-mouse.y);
1922
				 			xf=(yf/recorte);
1923
			 				y=0;
1924
			 				t3=false;
1925
			 			}
1926
			 			if(x+xf>(ancho)){
1927
			 				xf=(ancho)-x;
1928
				 			yf=xf*recorte;
1929
				 			t3=false;
1930
			 			}
1931
			 		}
1932
			 	}
1933
			 	if(t2){
1934
			 		if(mouse.y<(alto-10)&&x>=0){
1935
				 		if(Math.round(xf)>=50){
1936
							if(((mouse.y-y)/recorte)>50){
1937
					 			x=(x+(yf-(mouse.y-y))/recorte);
1938
					 			yf=mouse.y-y;
1939
					 			xf=(yf/recorte);
1940
				 			}
1941
					 	}
1942
 
1943
			 		}else{
1944
			 			if(mouse.y>=(alto-10)) {
1945
			 				yf=alto-y;
1946
				 			xf=(yf/recorte);
1947
				 			t2=false;
1948
			 			}
1949
			 			if(0>x){
1950
			 				x=0;
1951
			 				xf=mouse.y-y;
1952
				 			yf=(xf*recorte);
1953
				 			t2=false;
1954
			 			}
1955
			 		}
1956
			 	}
1957
			 	if(t1){
1958
			 		if(mouse.y>0&&x>=0){
1959
				 		if(Math.round(xf)>=50){
1960
							if(((yf+(y-mouse.y))/recorte)>50){
1961
								yf=yf+(y-mouse.y);
1962
					 			xf=(yf/recorte);
1963
					 			x=(x-(y-mouse.y)/recorte);
1964
					 			y=mouse.y;
1965
							}
1966
				 		}
1967
			 		}else{
1968
			 			if(mouse.y<=0) {
1969
			 				yf=yf+(y-mouse.y);
1970
				 			xf=(yf/recorte);
1971
			 				y=0;
1972
			 				t1=false;
1973
			 			}
1974
			 			if(0>x){
1975
			 				x=0;
1976
			 				xf=yf+(y-mouse.y);
1977
				 			yf=(xf*recorte);
1978
				 			t1=false;
1979
			 			}
1980
			 		}
1981
			 	}
1982
				}else{
1983
				 if(t4){
1984
			 		if(mouse.y<(alto-10-(2/scale))&&mouse.x<=(ancho-(2/scale))){
1985
 
1986
							if((mouse.y-y)>50){
1987
				 				yf=mouse.y-y;
1988
				 			}
1989
							if((mouse.x-x)>50){
1990
								xf=mouse.x-x;
1991
							}
1992
 
1993
			 		}else{
1994
			 			if(mouse.y>=(alto-10-(2/scale))){
1995
			 				yf=alto-y;
1996
			 			}
1997
			 			if(mouse.x>(ancho-(2/scale))){
1998
			 				xf=(ancho)-x;
1999
			 			}
2000
						 t4=false;
2001
			 		}
2002
			 	}
2003
			 	if(t3){
2004
			 		if(mouse.y>(2/scale)&&mouse.x<=(ancho-(2/scale))){
2005
 
2006
							if((yf-(mouse.y-y))>50){
2007
				 				yf=yf-(mouse.y-y);
2008
								y=mouse.y;
2009
				 			}
2010
							if((mouse.x-x)>50){
2011
								xf=mouse.x-x;
2012
							}
2013
 
2014
 
2015
			 		}else{
2016
						if(mouse.x>(ancho-(2/scale))){
2017
							xf=ancho-x;
2018
						}
2019
						if(mouse.y<=(2/scale)){
2020
							yf=yf-(mouse.y-y);
2021
							y=0;
2022
						}
2023
			 			t3=false;
2024
			 		}
2025
			 	}
2026
				/* Izquierda abajo */
2027
			 	if(t2){
2028
			 		if(mouse.y<(alto-10-(2/scale))&&mouse.x>=(2/scale)){
2029
							 if((mouse.y-y)>50){
2030
								yf=mouse.y-y;
2031
				 			}
2032
							if((xf-(mouse.x-x))>50){
2033
								xf=xf-(mouse.x-x);
2034
								x=mouse.x
2035
							}
2036
 
2037
			 		}else{
2038
			 			if(mouse.y>=(alto-10-(2/scale))) {
2039
							yf=alto-y;
2040
			 			}
2041
 
2042
			 			if(mouse.x<(2/scale)){
2043
							xf=xf-(mouse.x-x);
2044
			 				x=0;
2045
			 			}
2046
						 t2=false;
2047
			 		}
2048
			 	}
2049
				/* izquierda arriba */
2050
			 	if(t1){
2051
			 		if(mouse.y>(2/scale)&&mouse.x>=(2/scale)){
2052
 
2053
							if((yf-(mouse.y-y))>50){
2054
				 				yf=yf-(mouse.y-y);
2055
								y=mouse.y;
2056
				 			}
2057
							if((xf-(mouse.x-x))>50){
2058
								xf=xf-(mouse.x-x);
2059
								x=mouse.x
2060
							}
2061
 
2062
			 		}else{
2063
						if(mouse.y<=(2/scale)){
2064
							yf=yf-(mouse.y-y);
2065
							y=0;
2066
						}
2067
						 if(mouse.x<(2/scale)){
2068
							xf=xf-(mouse.x-x);
2069
			 				x=0;
2070
 
2071
			 			}
2072
						 t1=false;
2073
			 		}
2074
			 	}
2075
			}
2076
 
2077
		 	actualizar();
2078
		 	}else if(texto_listo){
2079
		 		if(tcli){
2080
		 			tx=mouse.x-(txf/2)
2081
		 			ty=mouse.y-(tyf/2)
2082
		 		}else if(rotar){
2083
 
2084
		 		}
2085
 
2086
		 		actualizar2();
2087
		 	}
2088
		 })
2089
		 $(elemento).mouseup(function(e){
2090
		 	if(!recorte_listo){
2091
			 	cli=false;
2092
			 	t1=false;
2093
			 	t2=false;
2094
			 	t3=false;
2095
			 	t4=false;
2096
		 	}else if (texto_listo) {
2097
		 		tcli=false;
2098
		 	}
2099
		 })
2100
 
2101
 
2102
	}
2103
	/* Titulo */
2104
 
2105
var titulo_noticia, censor_titulo = true, numero_titulo=0;
2106
	$(document).on("keyup change", "#name", function(e){
2107
	console.log(numero_titulo)
2108
	titulo_noticia = $(this).val();
2109
	titulo_elemento= $(".titulo_topico");
2110
	if(titulo_noticia!=""){
2111
		if(censor_titulo){
2112
			titulo_elemento.html(titulo_noticia);
2113
			if(titulo_elemento.height()>38){
2114
				var titulo_noticia2 = "";
2115
				for(var i =0; i <titulo_noticia.length;i++){
2116
					titulo_noticia2 = titulo_noticia2 + titulo_noticia.split("")[i];
2117
					titulo_elemento.html(titulo_noticia2);
2118
					if(titulo_elemento.height()>38){
2119
						titulo_noticia2 = titulo_noticia2.slice(0,-5) + "...";
2120
						titulo_elemento.html(titulo_noticia2);
2121
						numero_titulo = titulo_noticia2.length;
2122
						censor_titulo=false;
2123
						break;
2124
					}
2125
 
2126
				}
2127
			}else{
2128
				numero_titulo=0;
2129
			}
2130
		}else{
2131
			if(numero_titulo+1>=titulo_noticia.length){
2132
				titulo_elemento.html(titulo_noticia);
2133
				censor_titulo=true;
2134
			}
2135
		}
2136
	}else{
2137
		titulo_elemento.html("LABEL_TITLE");
2138
		censor_titulo = true;
2139
	}
2140
})
2141
 
1 www 2142
});
2143
JS;
2144
$this->inlineScript()->captureEnd();
2145
?>
2146
 
2147
 
2148
 
2149
<!-- Content Header (Page header) -->
2150
<section class="content-header">
2151
	<div class="container-fluid">
2152
    	<div class="row mb-2">
2153
        	<div class="col-sm-12">
2154
            	<h1>LABEL_CAPSULES</h1>
2155
			</div>
2156
		</div>
2157
	</div><!-- /.container-fluid -->
2158
</section>
2159
 
6704 nelberth 2160
<section class="content" id="content1">
1 www 2161
	<div class="container-fluid">
2162
    	<div class="row">
2163
        	<div class="col-12">
2164
				<div class="card">
2165
					<div class="card-header">
2166
						<?php
2167
                        $form = $this->form;
2168
            	        $form->setAttributes([
2169
                            'name'    => 'form-filter',
2170
                            'id'      => 'form-filter',
2171
                        ]);
2172
 
2173
                        $form->prepare();
2174
                        echo $this->form()->openTag($form);
2175
                        ?>
2176
                        <div class="form-group">
2177
                            <?php
2178
                            $element = $form->get('topic_uuid');
2179
 
2180
                            $element->setAttributes(['class' => 'form-control']);
2181
                            $element->setLabel('LABEL_TOPIC');
2182
                            echo $this->formLabel($element);
2183
                            echo $this->formSelect($element);
2184
                            ?>
2185
                        </div>
2186
						<?php echo $this->form()->closeTag($form); ?>
2187
					</div>
2188
					<div class="card-body">
20 steven 2189
        	    		<table id="gridTable" class="table   table-hover">
1 www 2190
                      		<thead>
2191
        						<tr>
2192
                                	<th>LABEL_NAME</th>
2193
                                  	<th>LABEL_DETAILS</th>
2194
                                  	<th>LABEL_IMAGES</th>
2195
                                  	<th>LABEL_ACTIONS</th>
2196
                                </tr>
2197
                       		</thead>
2198
                         	<tbody>
2199
                         	</tbody>
2200
                    	</table>
2201
                   	</div>
2202
                   	<div class="card-footer clearfix">
2203
                   		<div style="float:right;">
2204
							<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
2205
							<?php if($allowAdd) : ?>
2206
							<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
2207
							<?php endif; ?>
2208
						</div>
2209
                 	</div>
2210
          		</div>
2211
           	</div>
2212
        </div>
2213
 	</div>
2214
</section>
2215
 
2216
 
2217
<!-- The Modal -->
6694 nelberth 2218
<div id="modalCapsuleAdd" style='display:none'>
1 www 2219
 
6694 nelberth 2220
 
1 www 2221
            <!-- Modal Header -->
2222
 
6701 nelberth 2223
              <div class="d-flex justify-content-center tituloEditor">
2224
              <h4>LABEL_ADD_CAPSULE</h4>
2225
 
2226
             </div>
1 www 2227
            <!-- Modal body -->
6701 nelberth 2228
      		<div class="grid-padre">
1 www 2229
       			 <?php
2230
       			 $form = $this->formAdd;
2231
            		$form->setAttributes([
2232
                        'method'  => 'post',
2233
            		    'action'  => '',
2234
                        'name'    => 'form-capsule-add',
2235
                        'id'      => 'form-capsule-add',
2236
                    ]);
2237
 
2238
                    $form->prepare();
2239
                    echo $this->form()->openTag($form);
2240
                    ?>
6701 nelberth 2241
    				<div class="form-group grid-1-2">
1 www 2242
    				<?php
2243
                        $element = $form->get('name');
2244
 
2245
                        $element->setAttributes(['class' => 'form-control']);
2246
                        $element->setOptions(['label' => 'LABEL_NAME']);
2247
                        echo $this->formLabel($element);
2248
                        echo $this->formText($element);
2249
                    ?>
2250
				</div>
6701 nelberth 2251
                <div class="form-group grid-1-2">
1 www 2252
                	<?php
2253
                    $element = $form->get('description');
2254
                    $element->setAttributes(['id' => 'description_add', 'class' => 'form-control', 'rows' => '2','class' => 'form-control']);
2255
                    $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
2256
                    echo $this->formLabel($element);
2257
                    echo $this->formTextArea($element);
2258
                    ?>
2259
   				</div>
6701 nelberth 2260
				<div class="form-group grid-1-2">
1 www 2261
    				<?php
2262
                        $element = $form->get('order');
2263
                        $element->setAttributes(['class' => 'form-control']);
2264
                        $element->setOptions(['label' => 'LABEL_ORDER']);
2265
                        echo $this->formLabel($element);
2266
                        echo $this->formText($element);
2267
                    ?>
2268
				</div>
6854 nelberth 2269
 
6701 nelberth 2270
          		<div class="form-group grid-1-2">
1 www 2271
    				<?php
2272
                        $element = $form->get('status');
2273
                        $element->setAttributes(['class' => 'form-control']);
2274
                        $element->setOptions(['label' => 'LABEL_STATUS']);
2275
                        echo $this->formLabel($element);
2276
                        echo $this->formSelect($element);
2277
                    ?>
2278
				</div>
6701 nelberth 2279
				<div class="form-group grid-1-2">
1 www 2280
    				<?php
2281
                        $element = $form->get('privacy');
2282
                        $element->setAttributes(['class' => 'form-control']);
2283
                        $element->setOptions(['label' => 'LABEL_PRIVACY']);
2284
                        echo $this->formLabel($element);
2285
                        echo $this->formSelect($element);
2286
                    ?>
2287
				</div>
6701 nelberth 2288
				<div class="form-group grid-1-2">
1 www 2289
    				<?php
2290
                        $element = $form->get('type');
2291
                        $element->setAttributes(['class' => 'form-control']);
2292
                        $element->setOptions(['label' => 'LABEL_TYPE']);
2293
                        echo $this->formLabel($element);
2294
                        echo $this->formSelect($element);
2295
                    ?>
2296
				</div>
6701 nelberth 2297
				<div class="form-group grid-1-2" id="form-row-cost">
1 www 2298
    				<?php
2299
                        $element = $form->get('cost');
2300
                        $element->setAttributes(['class' => 'form-control']);
2301
                        $element->setOptions(['label' => 'LABEL_COST']);
2302
                        echo $this->formLabel($element);
2303
                        echo $this->formText($element);
2304
                    ?>
2305
				</div>
6861 nelberth 2306
 
2307
				<?php
1 www 2308
                    $element = $form->get('marketplace');
6861 nelberth 2309
					$element->setAttributes([ 'class' => 'marketplace']);
2310
                    echo $this->formHidden($element);
2311
                ?>
2312
                <?php
6854 nelberth 2313
                    $element = $form->get('file');
2314
					$element->setAttributes([ 'class' => 'file']);
2315
                    echo $this->formHidden($element);
2316
                ?>
6907 nelberth 2317
				<div class="form-group grid-1-2 ">
2318
					<div class="imagen-contaner">
7000 nelberth 2319
						<label for="marketplaceImg">LABEL_IMAGE_MARKETPLACE</label>
6997 nelberth 2320
						<img class='marketplaceImg' src='' class="img img-responsive" style="width: 100px; height: auto"></img>
6907 nelberth 2321
					</div>
6903 nelberth 2322
				</div>
7000 nelberth 2323
				<h5 style="text-align:center " class="form-group grid-1-2" id='titleTypeImage'>LABEL_IMAGE_MARKETPLACE</h5>
6854 nelberth 2324
          		<div class="contenido form-group " id="contenido"></div>
6823 nelberth 2325
 
1 www 2326
     	      		<?php echo $this->form()->closeTag($form); ?>
2327
      		</div>
2328
 
2329
 
6694 nelberth 2330
 
1 www 2331
</div>
2332
 
2333
 
2334
<!-- The Modal -->
6977 nelberth 2335
<div  id="modalCapsuleEdit" style='display:none'>
1 www 2336
 
6976 nelberth 2337
 
1 www 2338
            <!-- Modal Header -->
2339
 
6976 nelberth 2340
			<div class="d-flex justify-content-center tituloEditor">
2341
              <h4>LABEL_EDIT_CAPSULE</h4>
2342
 
2343
             </div>
1 www 2344
            <!-- Modal body -->
6976 nelberth 2345
      		<div class="grid-padre">
2346
			  <?php
1 www 2347
       			  $form = $this->formEdit;
2348
            		$form->setAttributes([
2349
                        'method'    => 'post',
2350
                        'name'      => 'form-capsule-edit',
2351
                        'id'        => 'form-capsule-edit'
2352
                    ]);
2353
 
2354
                    $form->prepare();
2355
                    echo $this->form()->openTag($form);
6976 nelberth 2356
                ?>
2357
    				<div class="form-group grid-1-2">
1 www 2358
    				<?php
2359
                        $element = $form->get('name');
6976 nelberth 2360
 
1 www 2361
                        $element->setAttributes(['class' => 'form-control']);
2362
                        $element->setOptions(['label' => 'LABEL_NAME']);
2363
                        echo $this->formLabel($element);
2364
                        echo $this->formText($element);
2365
                    ?>
2366
				</div>
6976 nelberth 2367
                <div class="form-group grid-1-2">
1 www 2368
                	<?php
2369
                    $element = $form->get('description');
6978 nelberth 2370
                    $element->setAttributes(['id' => 'description_edit', 'class' => 'form-control', 'rows' => '2','class' => 'form-control']);
1 www 2371
                    $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
2372
                    echo $this->formLabel($element);
2373
                    echo $this->formTextArea($element);
2374
                    ?>
2375
   				</div>
6976 nelberth 2376
				<div class="form-group grid-1-2">
1 www 2377
    				<?php
2378
                        $element = $form->get('order');
2379
                        $element->setAttributes(['class' => 'form-control']);
2380
                        $element->setOptions(['label' => 'LABEL_ORDER']);
2381
                        echo $this->formLabel($element);
2382
                        echo $this->formText($element);
2383
                    ?>
2384
				</div>
6976 nelberth 2385
 
2386
          		<div class="form-group grid-1-2">
1 www 2387
    				<?php
2388
                        $element = $form->get('status');
2389
                        $element->setAttributes(['class' => 'form-control']);
2390
                        $element->setOptions(['label' => 'LABEL_STATUS']);
2391
                        echo $this->formLabel($element);
2392
                        echo $this->formSelect($element);
2393
                    ?>
2394
				</div>
6976 nelberth 2395
				<div class="form-group grid-1-2">
1 www 2396
    				<?php
2397
                        $element = $form->get('privacy');
2398
                        $element->setAttributes(['class' => 'form-control']);
2399
                        $element->setOptions(['label' => 'LABEL_PRIVACY']);
2400
                        echo $this->formLabel($element);
2401
                        echo $this->formSelect($element);
2402
                    ?>
2403
				</div>
6976 nelberth 2404
				<div class="form-group grid-1-2">
1 www 2405
    				<?php
2406
                        $element = $form->get('type');
2407
                        $element->setAttributes(['class' => 'form-control']);
2408
                        $element->setOptions(['label' => 'LABEL_TYPE']);
2409
                        echo $this->formLabel($element);
2410
                        echo $this->formSelect($element);
2411
                    ?>
2412
				</div>
6976 nelberth 2413
				<div class="form-group grid-1-2" id="form-row-cost">
1 www 2414
    				<?php
2415
                        $element = $form->get('cost');
2416
                        $element->setAttributes(['class' => 'form-control']);
2417
                        $element->setOptions(['label' => 'LABEL_COST']);
2418
                        echo $this->formLabel($element);
2419
                        echo $this->formText($element);
2420
                    ?>
2421
				</div>
6976 nelberth 2422
 
2423
				<?php
2424
                    $element = $form->get('marketplace');
2425
					$element->setAttributes([ 'class' => 'marketplace']);
2426
                    echo $this->formHidden($element);
2427
                ?>
2428
                <?php
2429
                    $element = $form->get('file');
2430
					$element->setAttributes([ 'class' => 'file']);
2431
                    echo $this->formHidden($element);
2432
                ?>
2433
				<div class="form-group grid-1-2 ">
2434
					<div class="imagen-contaner">
7000 nelberth 2435
						<label for="marketplaceImg">LABEL_IMAGE_MARKETPLACE</label>
6997 nelberth 2436
						<img class='marketplaceImg' src='' class="img img-responsive" style="width: 100px; height: auto"></img>
6976 nelberth 2437
					</div>
2438
				</div>
7000 nelberth 2439
				<h5 style="text-align:center " class="form-group grid-1-2" id='titleTypeImage'>LABEL_IMAGE_MARKETPLACE</h5>
6976 nelberth 2440
          		<div class="contenido form-group " id="contenido"></div>
2441
 
1 www 2442
     	      		<?php echo $this->form()->closeTag($form); ?>
2443
      		</div>
2444
 
6976 nelberth 2445
 
1 www 2446
</div>
2447
 
2448
 
2449
 
2450
<!-- The Modal -->
2451
<div class="modal" id="modalAppMarkeplate">
2452
	<div class="modal-dialog">
2453
		<div class="modal-content">
2454
        	<!-- Modal Header -->
2455
        	<div class="modal-header">
2456
           		<h4 class="modal-title">LABEL_IMAGE_MARKETPLACE</h4>
2457
        		<button type="button" class="close" data-dismiss="modal">&times;</button>
2458
      		</div>
2459
 
2460
           	<!-- Modal body -->
2461
           	<div class="modal-body text-center">
2462
    			<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-marketplace" />
2463
          	</div>
2464
 
2465
            <!-- Modal footer -->
2466
  			<div class="modal-footer">
2467
    			<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
2468
      		</div>
2469
      	</div>
2470
	</div>
2471
</div>
2472
 
2473
 
2474
<!-- The Modal -->
2475
<div class="modal" id="modalImageApp">
2476
	<div class="modal-dialog ">
2477
    	<div class="modal-content">
2478
 
2479
            <!-- Modal Header -->
2480
      		<div class="modal-header">
2481
        		<h4 class="modal-title">LABEL_IMAGE</h4>
2482
        		<button type="button" class="close" data-dismiss="modal">&times;</button>
2483
      		</div>
2484
 
2485
            <!-- Modal body -->
2486
            <div class="modal-body text-center">
2487
				<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-app" />
2488
      		</div>
2489
 
2490
            <!-- Modal footer -->
2491
      		<div class="modal-footer">
2492
        		<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
2493
          	</div>
2494
         </div>
2495
	</div>
2496
</div>
2497
 
2498
 
2499
 
2500
 
2501
 
2502
 
2503
<!-- The Modal -->
2504
<div class="modal" id="notificationUsersModal">
2505
	<div class="modal-dialog modal-xl">
2506
    	<div class="modal-content">
2507
 
2508
            <!-- Modal Header -->
2509
      		<div class="modal-header">
2510
        		<h4 class="modal-title">LABEL_USERS</h4>
2511
        		<button type="button" class="close" data-dismiss="modal">&times;</button>
2512
      		</div>
2513
 
2514
            <!-- Modal body -->
2515
      		<div class="modal-body">
2516
      			<form>
2517
      				<div class="form-group">
2518
      					<label>LABEL_TOPIC</label>
2519
      					<input type="text" readonly="readonly" id="table-users-topic" class="form-control" >
2520
      				</div>
2521
      				<div class="form-group">
2522
      					<label>LABEL_CAPSULE</label>
2523
      					<input type="text" readonly="readonly" id="table-users-capsule" class="form-control" >
2524
      				</div>
2525
      			</form>
2526
      			<div style="height: 300px;overflow: scroll;">
20 steven 2527
				<table id="gridTableUsers" style="width: 100%" class="table   table-hover">
1 www 2528
            		<thead>
2529
            			<tr>
2530
                      		<th>LABEL_FIRST_NAME</th>
2531
                     		<th>LABEL_LAST_NAME</th>
2532
                         	<th>LABEL_EMAIL</th>
2533
                       		<th>LABEL_DETAILS</th>
2534
             			</tr>
2535
                  	</thead>
2536
               		<tbody>
2537
               		</tbody>
2538
         		</table>
2539
         		</div>
2540
 
2541
      		</div>
2542
 
2543
            <!-- Modal footer -->
2544
      		<div class="modal-footer">
2545
        		<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
2546
      		</div>
2547
 
2548
    	</div>
2549
	</div>
2550
</div>
2551
 
2552
 
2553
 
2554
 
2555
 
2556
 
2557
 
2558