Proyectos de Subversion LeadersLinked - Backend

Rev

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