Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 12079 | Rev 16822 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php 
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
$currentUser    = $this->currentUserHelper();
$roleName       = $currentUser->getUserTypeId();

$routeDatatable = $this->url('microlearning/content/slides');

$allowAdd = $acl->isAllowed($roleName, 'microlearning/content/slides/add') ? 1 : 0;
$allowEdit = $acl->isAllowed($roleName, 'microlearning/content/slides/edit') ? 1 : 0;
$allowDelete = $acl->isAllowed($roleName, 'microlearning/content/slides/delete') ? 1 : 0;


$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));


$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));



$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/css/fileinput.min.css'));
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fa/theme.css'));

$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/piexif.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/sortable.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/fileinput.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/locales/es.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/fa/theme.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fa/theme.js'));

$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));

$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));

$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));

$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));


$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));

$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));

$this->headLink()->appendStylesheet($this->basePath('plugins/nelberth-editor/style.css'));



$this->inlineScript()->captureStart();
echo <<<JS


jQuery( document ).ready(function( $ ) {

        var routeAdd = '';

        $.validator.setDefaults({
            debug: true,
            highlight: function(element) {
                $(element).addClass('is-invalid');
            },
            unhighlight: function(element) {
                $(element).removeClass('is-invalid');
            },
            errorElement: 'span',
            errorClass: 'error invalid-feedback',
            errorPlacement: function(error, element) {

            }
        });
    
    
        $.fn.showFormErrorValidator = function(fieldname, errors) {
            var field = $(fieldname);
            if(field) {
                $(field).addClass('is-invalid');
    

                var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
                if(element.parent('.btn-file').length) {
                    error.insertAfter(element.parent().parent());
                } else if(element.parent('.toggle').length) {
                    error.insertAfter(element.parent().parent());
                } else {
                    error.insertAfter(element.parent());
                }
            }
        };
        
    var allowEdit   = $allowEdit;
        var allowDelete = $allowDelete;
        
        var gridTable = $('#gridTable').dataTable( {
            'processing': true,
            'serverSide': true,
            'searching': true,
            'order': [[ 0, 'asc' ]],
            'ordering':  true,
            'ordenable' : true,
            'responsive': true,
            'select' : false,
                'paging': true,
            'pagingType': 'simple_numbers',

                'ajax': {
                        'url' : '$routeDatatable',
                        'type' : 'get',
                'data': function ( d ) {
                    d.topic_uuid = $('#form-filter #topic_uuid').val();
                    d.capsule_uuid = $('#form-filter #capsule_uuid').val();
               
                },
                'beforeSend': function (request) {
                  NProgress.start();
                },
                'dataFilter': function(response) {
                    var response = jQuery.parseJSON( response );
                    
                    var json                = {};
                    json.recordsTotal       = 0;
                    json.recordsFiltered    = 0;
                    json.data               = [];
                    
                    if(response.success) {
                        $('#form-capsule-add').attr('action', response.data.link_add ); 

                        if(response.data.capsules) {
                            $('#form-filter #capsule_uuid').empty();
                            $.each(response.data.capsules, function(index, value) {
                                  $('#form-filter #capsule_uuid').append('<option value="' + index + '">' + value + '</option>')
                            });
                        } 

                        routeAdd = response.data.link_add;
                        if(response.data.link_add) {
                            
                            $('button.btn-add').removeAttr('disabled'); 
                        } else {
                            $('button.btn-add').attr('disabled', 'disabled'); 
                        } 

                        json.recordsTotal       = response.data.total;
                        json.recordsFiltered    = response.data.total;
                        json.data               = response.data.items;
                    } else {
                        $.fn.showError(response.data)
                    }
                    
                    return JSON.stringify( json );
                }
                },
            'language' : {
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
                'sInfo':           'LABEL_DATATABLE_SINFO',
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
                'sInfoPostFix':    '',
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
                'sUrl':            '',
                'sInfoThousands':  ',',
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
                'oPaginate': {
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
                    'sLast':     'LABEL_DATATABLE_SLAST',
                    'sNext':     'LABEL_DATATABLE_SNEXT',
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
                },
                'oAria': {
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
                },
            },
            'drawCallback': function( settings ) {
                NProgress.done();
                $('button.btn-delete').confirmation({
                    rootSelector: 'button.btn-delete',
                    title : 'LABEL_ARE_YOU_SURE',
                    singleton : true,
                    btnOkLabel: 'LABEL_YES',
                    btnCancelLabel: 'LABEL_NO',
                    onConfirm: function(value) {
                        action = $(this).data('href');
                        NProgress.start();
                        $.ajax({
                            'dataType'  : 'json',
                            'accept'    : 'application/json',
                            'method'    : 'post',
                            'url'       :  action,
                        }).done(function(response) {
                            if(response['success']) {
                                $.fn.showSuccess(response['data']);
                                gridTable.api().ajax.reload(null, false);
                            } else {
                                $.fn.showError(response['data']);
                            }
                        }).fail(function( jqXHR, textStatus, errorThrown) {
                            $.fn.showError(textStatus);
                        }).always(function() {
                            NProgress.done();
                        });
                    },
                });
            },
            'aoColumns': [
                { 'mDataProp': 'name' },
                { 'mDataProp': 'details' },
                { 'mDataProp': 'media' },
                { 'mDataProp': 'actions' },
            ],
            'columnDefs': [
                {
                    'targets': 0,
                    'className' : 'text-vertical-middle',
                },
                {
                    'targets': -3,
                    'orderable': false,
                    'render' : function ( data, type, row ) {
                        var s = '';
                        s += 'LABEL_TYPE: ' + data['type']  + '<br/>';
                        return s;
                    }
                },
                {
                    'targets': -2,
                    'orderable': false,
                    'render' : function ( data, type, row ) {
                        s = '';
                        if( data['image'] )  {
                            s = s + '&nbsp; <img class="btn-view-image"" data-href="' + data['image'] + '" data-toggle="tooltip" src="'+data['image']+'" title="LABEL_VIEW" style="width: 40px; object-fit: cover; height: 40px;" /> ';    
                        } 

                        if( data['audio'] )  {
                            s = s + '&nbsp;<button class="btn btn-play-audio" data-href="' + data['audio'] + '" data-toggle="tooltip" title="LABEL_PLAY_AUDIO"><i class="fa fa-play"></i></button> <br>';    
                        } 
                        
                        if( data['video'] )  {
                            s = s + '&nbsp;<button class="btn btn-play-video" data-href="' + data['video'] + '" data-toggle="tooltip" title="LABEL_PLAY_VIDEO"><i class="fa fa-video-camera"></i></button> <br>';    
                        }

                       
                        if( data['document'] )  {
                            s = s + '&nbsp;<button class="btn btn-view-document" data-href="' + data['document'] + '" data-toggle="tooltip" title="LABEL_VIEW_DOCUMENT"><i class="fa fa-file"></i></button> <br>';    
                        } 

                        if( data['text'] )  {
                            s = s + '&nbsp;<button class="btn btn-view-text" data-href="' + data['text'] + '" data-toggle="tooltip" title="LABEL_VIEW_TEXT"><i class="fa fa-text-width"></i></button> <br>';    
                        }  

                        return s;
                    }
                },


                {
                    'targets': -1,
                    'orderable': false,
                    'render' : function ( data, type, row ) {
                        s = '';
                        
                        if(allowEdit && data['link_edit']  ) {
                            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> Editar </button>&nbsp;';
                        }
                        if(allowDelete && data['link_delete']  ) {
                            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> Eliminar</button>&nbsp;';
                        }
                        return s;
                    }
                }
              ],
        });
        var seleccionarCampo;
    var validatorTextAdd  = $('#form-slide-text-add').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
            'description': {
                updateCkeditor:function() {
                        CKEDITOR.instances.description_add.updateElement();
                },
                required: true
            },
           'background': {
                required: true,
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {

            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }

            
                                $('.info_noticia').prop('disabled', true);
            NProgress.start();
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  routeAdd,
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        seleccionarCampo.css('display','none');
                    
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorTextAdd.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-text-add #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
                
                                $('.info_noticia').prop('disabled', false);
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });

    var validatorTextEdit = $('#form-slide-text-edit').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
            'description': {
                updateCkeditor:function() {
                        CKEDITOR.instances.description_edit.updateElement();
                },
                required: true
            },
           'background': {
                required: true,
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }

            
                                $('.info_noticia').prop('disabled', true);
            NProgress.start();
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  $('#form-slide-text-edit').attr('action'),
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                       
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        seleccionarCampo.css('display','none');

                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorTextEdit.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-text-edit #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
                
                                $('.info_noticia').prop('disabled', false);
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });

    var validatorImageAdd  = $('#form-slide-image-add').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
           'file': {
                required: true,
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }

            
                                $('.info_noticia').prop('disabled', true);
            NProgress.start();
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  routeAdd,
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                console.log(response)
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        
                        seleccionarCampo.css('display','none');
                    
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorImageAdd.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-image-add #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
                
                                $('.info_noticia').prop('disabled', false);
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });

    var validatorImageEdit = $('#form-slide-image-edit').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
            'file': {
                required: true,
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }
            
                                $('.info_noticia').prop('disabled', true);
            NProgress.start();
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  $('#form-slide-image-edit').attr('action'),
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                       
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        
                        seleccionarCampo.css('display','none');
                    
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorImageEdit.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-image-edit #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
                
                                $('.info_noticia').prop('disabled', false);
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });

    var validatorVideoAdd  = $('#form-slide-video-add').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
           'file': {
                required: true,
                extension: 'webm,mp4,webm',
                accept: 'video/webm,video/mpeg,video/mp4'
            },
            'background': {
                required: true,
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }

            
                        $('.info_noticia').prop('disabled', true);
            NProgress.start();
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  routeAdd,
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
     
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        seleccionarCampo.css('display','none');
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorVideoAdd.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-video-add #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
                                $('.info_noticia').prop('disabled', false);
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });

    var validatorVideoEdit = $('#form-slide-video-edit').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
            'file': {
                required: false,
                extension: 'webm,mp4,webm',
                accept: 'video/webm,video/mpeg,video/mp4'
            },
            'background': {
                required: true
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }

           
                        $('.info_noticia').prop('disabled', true);
            NProgress.start();
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  $('#form-slide-video-edit').attr('action'),
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                       
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        seleccionarCampo.css('display','none');
                    
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorVideoEdit.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-video-edit #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                                $('.info_noticia').prop('disabled', false);
                NProgress.done();
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });


    var validatorDocumentAdd  = $('#form-slide-document-add').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
           'file': {
                required: true,
                extension: 'pdf',
                accept: 'application/pdf'
            },
           'background': {
                required: true,
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }

            
                        $('.info_noticia').prop('disabled', true);
            NProgress.start();
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  routeAdd,
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                       
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        seleccionarCampo.css('display','none');
                    
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorDocumentAdd.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-document-add #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                                $('.info_noticia').prop('disabled', false);
                NProgress.done();
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });

    var validatorDocumentEdit = $('#form-slide-document-edit').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
           'file': {
                required: false,
                extension: 'pdf',
                accept: 'application/pdf'
            },
           'background': {
                required: true,
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }

            
                        $('.info_noticia').prop('disabled', true);
            NProgress.start();
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  $('#form-slide-document-edit').attr('action'),
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                       
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        seleccionarCampo.css('display','none');
                    
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorDocumentEdit.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-document-edit #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                                $('.info_noticia').prop('disabled', false);
                NProgress.done();
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });

    var validatorAudioAdd  = $('#form-slide-audio-add').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
           'file': {
                required: true,
                extension: 'wav|mp3',
                accept: 'audio/wav, audio/mpeg'
            },

           'background': {
                required: true
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }

            
                        $('.info_noticia').prop('disabled', true);
            NProgress.start();
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  routeAdd,
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                       
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        seleccionarCampo.css('display','none');
                    
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorAudioAdd.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-audio-add #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
                
                                $('.info_noticia').prop('disabled', false);
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });

    var validatorAudioEdit = $('#form-slide-audio-edit').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
           'file': {
                required: false,
                extension: 'wav|mp3',
                accept: 'audio/wav, audio/mpeg'
            },

           'background': {
                required: true,
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }

            
                                $('.info_noticia').prop('disabled', true);
            NProgress.start();
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  $('#form-slide-audio-edit').attr('action'),
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                       
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        seleccionarCampo.css('display','none');
                    
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorAudioEdit.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-audio-edit #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                                $('.info_noticia').prop('disabled', false);
                NProgress.done();
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });

    var validatorQuizzAdd  = $('#form-slide-quizz-add').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
           'file': {
                required: true,
                extension: 'wav|mp3',
                accept: 'quizz/wav, quizz/mpeg'
            },
            'background': {
                required: true,
            },
            'quiz_id': {
                required: true,
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {

            
                                $('.info_noticia').prop('disabled', true);
            NProgress.start();
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }

            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  routeAdd,
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                       
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        seleccionarCampo.css('display','none');
                    
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorQuizzAdd.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-quizz-add #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
                
                                $('.info_noticia').prop('disabled', true);
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });

    var validatorQuizzEdit = $('#form-slide-quizz-edit').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 128,
            },
           'background': {
                required: true,
            },
            'quiz_id': {
                required: true,
            },
            'order' : {
                required: true,
                digits: true,
                min: 1,
                max: 250
            }
        },
        submitHandler: function(form)
        {

            $('.info_noticia').prop('disabled', true);
            NProgress.start();
            var formdata = false;
            if (window.FormData){
                formdata = new FormData(form); //form[0]);
            }
            $.ajax({
                'dataType'  : 'json',
                'accept'    : 'application/json',
                'method'    : 'post',
                'url'       :  $('#form-slide-quizz-edit').attr('action'),
                'data'      :  formdata,
                'processData': false,
                'contentType': false,
            }).done(function(response) {
                if(response['success']) {
                    $.fn.showSuccess(response['data']);
                       
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','block');
                    $('.contenido').html(''); 
                        seleccionarCampo.css('display','none');
                    
                    gridTable.api().ajax.reload(null, false);
                } else {
                    validatorQuizzEdit.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form-slide-quizz-edit #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
                
                                $('.info_noticia').prop('disabled', false);
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });
   
    $('body').on('click', 'button.btn-edit', function(e) {
        e.preventDefault();
        NProgress.start();
        var url = $(this).data('href');     
        $.ajax({
            'dataType'  : 'json',
            'accept'    : 'application/json',
            'method'    : 'get',
            'url'       :  url,
        }).done(function(response) {
            if(response['success']) {

                if(response['data']['type'] == 'text') {
                    $('#form-slide-text-edit').attr('action',url);
                    $('#form-slide-text-edit #name').val(response['data']['name']);
                    $('#form-slide-text-edit #order').val(response['data']['order']);
    
                    CKEDITOR.instances.description_edit.setData(response['data']['description']);
                    validatorTextEdit.resetForm();
            
                    
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','none');
                    seleccionarCampo= $('#company-microlearning-slide-text-edit-box');
                    seleccionarCampo.css('display','block')
                            iniciarEditor(seleccionarCampo,response['data']['background'])
                    
                }
                if(response['data']['type'] == 'image') {
                    console.log(response['data']['file'])
                    $('#form-slide-image-edit').attr('action',url);
                    $('#form-slide-image-edit #name').val(response['data']['name']);
                    $('#form-slide-image-edit #order').val(response['data']['order']);
                    validatorImageEdit.resetForm();
            
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','none');
                    seleccionarCampo=  $('#company-microlearning-slide-image-edit-box ');
                    seleccionarCampo.css('display','block')
                            iniciarEditor(seleccionarCampo,response['data']['file'])
                    
                }
                if(response['data']['type'] == 'video') {
                    $('#form-slide-video-edit').attr('action',url);
                    $('#form-slide-video-edit #name').val(response['data']['name']);
                    $('#form-slide-video-edit #order').val(response['data']['order']);
                    $('#form-slide-video-edit #file').fileinput('reset');
                    $('#form-slide-video-edit #file').val('');
                    validatorVideoEdit.resetForm();
            
                   

                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','none');
                    seleccionarCampo= $('#company-microlearning-slide-video-edit-box');
                    seleccionarCampo.css('display','block')
                            iniciarEditor(seleccionarCampo,response['data']['background'])
                    
                }
                if(response['data']['type'] == 'document') {
                    $('#form-slide-document-edit').attr('action',url);
                    $('#form-slide-document-edit #name').val(response['data']['name']);
                    $('#form-slide-document-edit #order').val(response['data']['order']);
                    $('#form-slide-document-edit #file').fileinput('reset');
                    $('#form-slide-document-edit #file').val('');
                    validatorDocumentEdit.resetForm();
            
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','none');
                    seleccionarCampo= $('#company-microlearning-slide-document-edit-box');
                    seleccionarCampo.css('display','block')
                            iniciarEditor(seleccionarCampo,response['data']['background'])
                    
                }
                if(response['data']['type'] == 'audio') {
                    $('#form-slide-audio-edit').attr('action',url);
                    $('#form-slide-audio-edit #name').val(response['data']['name']);
                    $('#form-slide-audio-edit #order').val(response['data']['order']);
                    $('#form-slide-audio-edit #file').fileinput('reset');
                    $('#form-slide-audio-edit #file').val('');
                    validatorAudioEdit.resetForm();
            
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','none');
                    seleccionarCampo= $('#company-microlearning-slide-audio-edit-box');
                    seleccionarCampo.css('display','block')
                            iniciarEditor(seleccionarCampo,response['data']['background'])
                    
                    
                }
                if(response['data']['type'] == 'quiz') {
                    $('#form-slide-quizz-edit').attr('action',url);
                    $('#form-slide-quizz-edit #name').val(response['data']['name']);
                    $('#form-slide-quizz-edit #order').val(response['data']['order']);
                    $('#form-slide-quizz-edit #quiz_id').val(response['data']['quiz_id']);
                    validatorQuizzEdit.resetForm();
            
                    $('body, html').animate({scrollTop: '0px'}, 300);
                                        $('#content1').css('display','none');
                    seleccionarCampo= $('#company-microlearning-slide-quizz-edit-box');
                    seleccionarCampo.css('display','block')
                            iniciarEditor(seleccionarCampo,response['data']['background'])
                    
                }

            } else {
                validatorTextEdit.resetForm();
                if(jQuery.type(response['data']) == 'string') {
                    $.fn.showError(response['data']);
                } else  {
                    $.each(response['data'], function( fieldname, errors ) {
                        $.fn.showFormErrorValidator('#form-slide-image-edit #' + fieldname, errors);
                    });
                }
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });
    });
        $('body').on('click', '#ir_atras', function(e) {
            e.preventDefault();
            $('body, html').animate({scrollTop: '0px'}, 300);
                        $('#content1').css('display','block');
            seleccionarCampo.css('display','none');
            $('.contenido').html('');          
            return false;
        });
    $(".btn-cover-close").on("click", function(e){
        e.preventDefault();

        
        $('#company-microlearning-slide-text-add-box').modal('hide');
        $('#company-microlearning-slide-text-edit-box').modal('hide');
        $('#company-microlearning-slide-image-add-box').modal('hide');
        $('#company-microlearning-slide-image-edit-box').modal('hide');
        $('#company-microlearning-slide-video-add-box').modal('hide');
        $('#company-microlearning-slide-video-edit-box').modal('hide');
        $('#company-microlearning-slide-document-add-box').modal('hide');
        $('#company-microlearning-slide-document-edit-box').modal('hide');
        $('#company-microlearning-slide-audio-add-box').modal('hide');
        $('#company-microlearning-slide-audio-edit-box').modal('hide');
        $('#company-microlearning-slide-quizz-add-box').modal('hide');
        $('#company-microlearning-slide-quizz-edit-box').modal('hide');
        $('#company-microlearning-play-video-box').modal('hide');
        $('#company-microlearning-play-audio-box').modal('hide');
        $('#company-microlearning-add-capsule-type-box').modal('hide');
        


         document.getElementById('microlearning-play-video').pause();
         document.getElementById('microlearning-play-audio').pause();
        
        return false;
    });

    $('body').on('click', 'button.btn-add-quizz', function(e) {
        e.preventDefault();
        $('#company-microlearning-add-capsule-type-box').modal('hide');


        $('#form-slide-quizz-add #name').val('');
        $('#form-slide-quizz-add #order').val('1');
        $('#form-slide-quizz-add #quiz_id').val('');
        CKEDITOR.instances.description_add.setData('');
        validatorQuizzAdd.resetForm();


        $('body, html').animate({scrollTop: '0px'}, 300);
                $('#content1').css('display','none');
        seleccionarCampo= $('#company-microlearning-slide-quizz-add-box');
        seleccionarCampo.css('display','block')
                iniciarEditor(seleccionarCampo)
        
        return false;
    });

    $('body').on('click', 'button.btn-add-text', function(e) {
        e.preventDefault();

        $('#company-microlearning-add-capsule-type-box').modal('hide');    

        $('#form-slide-text-add #name').val('');
        $('#form-slide-text-add #order').val('1');
        CKEDITOR.instances.description_add.setData('');
        validatorTextAdd.resetForm();

        $('body, html').animate({scrollTop: '0px'}, 300);
                $('#content1').css('display','none');
        seleccionarCampo =  $('#company-microlearning-slide-text-add-box');
        seleccionarCampo.css('display','block')
                iniciarEditor(seleccionarCampo)
        return false;
    });


    $('body').on('click', 'button.btn-add-image', function(e) {
        e.preventDefault();

        $('#company-microlearning-add-capsule-type-box').modal('hide');    
        $('#form-slide-image-add #name').val('');
        $('#form-slide-image-add #order').val('1');
        
        validatorImageAdd.resetForm();

        $('body, html').animate({scrollTop: '0px'}, 300);
                $('#content1').css('display','none');
        seleccionarCampo =  $('#company-microlearning-slide-image-add-box');
        seleccionarCampo.css('display','block')
                iniciarEditor(seleccionarCampo)
            
        return false;
    });

    $('body').on('click', 'button.btn-add-video', function(e) {
        e.preventDefault();

        $('#company-microlearning-add-capsule-type-box').modal('hide');    
        $('#form-slide-video-add #name').val('');
        $('#form-slide-video-add #order').val('1');
        $('#form-slide-video-add #file').fileinput('reset');
        $('#form-slide-video-add #file').val('');
        $('#form-slide-video-add #file').fileinput('reset');
        $('#form-slide-video-add #file').val('');
        validatorVideoAdd.resetForm();

     
        $('body, html').animate({scrollTop: '0px'}, 300);
                $('#content1').css('display','none');
        seleccionarCampo =  $('#company-microlearning-slide-video-add-box');
        seleccionarCampo.css('display','block')
                iniciarEditor(seleccionarCampo)
        
        return false;
    });

    $('body').on('click', 'button.btn-add-document', function(e) {
        e.preventDefault();


        $('#company-microlearning-add-capsule-type-box').modal('hide');    
        $('#form-slide-document-add #name').val('');
        $('#form-slide-document-add #order').val('1');
        $('#form-slide-document-add #file').fileinput('reset');
        $('#form-slide-document-add #file').val('');
        validatorDocumentAdd.resetForm();

        $('body, html').animate({scrollTop: '0px'}, 300);
                $('#content1').css('display','none');
        seleccionarCampo =  $('#company-microlearning-slide-document-add-box');
        seleccionarCampo.css('display','block')
                iniciarEditor(seleccionarCampo)
        
        return false;
    });

    $('body').on('click', 'button.btn-add-audio', function(e) {
        e.preventDefault();

        $('#company-microlearning-add-capsule-type-box').modal('hide');    
        $('#form-slide-audio-add #name').val('');
        $('#form-slide-audio-add #order').val('1');
        $('#form-slide-audio-add #file').fileinput('reset');
        $('#form-slide-audio-add #file').val('');
        validatorAudioAdd.resetForm();

        $('body, html').animate({scrollTop: '0px'}, 300);
                $('#content1').css('display','none');
        seleccionarCampo =  $('#company-microlearning-slide-audio-add-box');
        seleccionarCampo.css('display','block')
                iniciarEditor(seleccionarCampo)
        
        return false;
    });

    $('#company-microlearning-slide-text-add-box, #company-microlearning-slide-text-edit-box').on("hide.bs.modal", function() {
        
    })

    $('#company-microlearning-slide-image-add-box, #company-microlearning-slide-image-edit-box').on("hide.bs.modal", function() {
        
    })

    $('#company-microlearning-slide-video-add-box, #company-microlearning-slide-video-edit-box').on("hide.bs.modal", function() {
        
    })

    $('#company-microlearning-slide-document-add-box, #company-microlearning-slide-document-edit-box').on("hide.bs.modal", function() {
        
    })

    $('#company-microlearning-slide-quizz-add-box, #company-microlearning-slide-quizz-edit-box').on("hide.bs.modal", function() {
        
    })

    $('#company-microlearning-play-video-box, #company-microlearning-play-audio-box').on("hide.bs.modal", function() {
        

        document.getElementById('microlearning-play-video').pause();
        document.getElementById('microlearning-play-audio').pause();
    })


    $('#form-slide-text-add #order').inputNumberFormat({decimal: 0});

 

    $('#form-slide-text-edit #order').inputNumberFormat({decimal: 0});



    $('#form-slide-image-add #order').inputNumberFormat({decimal: 0});

   

    $('#form-slide-image-edit #order').inputNumberFormat({decimal: 0});

    

    $('#form-slide-video-add #order').inputNumberFormat({decimal: 0});

    $('#form-slide-video-add #file').fileinput({
        theme: 'fa',
        language: 'es',
        showUpload: false,
        dropZoneEnabled: false,
        maxFileCount: 1,
        allowedFileExtensions: ['mp4', 'mpeg','webm'],
        msgPlaceholder: 'Video de extensión mp4, mpeg, webm',
    });



    $('#form-slide-video-edit #order').inputNumberFormat({decimal: 0});

    $('#form-slide-video-edit #file').fileinput({
        theme: 'fa',
        language: 'es',
        showUpload: false,
        dropZoneEnabled: false,
        maxFileCount: 1,
        allowedFileExtensions: ['mp4', 'mpeg','webm'],
        msgPlaceholder: 'Video de extensión mp4, mpeg, webm',
    });



  

    $('#form-slide-document-add #order').inputNumberFormat({decimal: 0});

    $('#form-slide-document-add #file').fileinput({
        theme: 'fa',
        language: 'es',
        showUpload: false,
        dropZoneEnabled: false,
        maxFileCount: 1,
        allowedFileExtensions: ['pdf'],
        msgPlaceholder: 'Documentos de extensión pdf',
    });




    $('#form-slide-document-edit #order').inputNumberFormat({decimal: 0});

    $('#form-slide-document-edit #file').fileinput({
        theme: 'fa',
        language: 'es',
        showUpload: false,
        dropZoneEnabled: false,
        maxFileCount: 1,
        allowedFileExtensions: ['pdf'],
        msgPlaceholder: 'Documentos de extensión pdf',
    });




    $('#form-slide-audio-add #order').inputNumberFormat({decimal: 0});

    $('#form-slide-audio-add #file').fileinput({
        theme: 'fa',
        language: 'es',
        showUpload: false,
        dropZoneEnabled: false,
        maxFileCount: 1,
        allowedFileExtensions: ['wav', 'mp3'],
        msgPlaceholder: 'Audios de extensión wav y mp3',
    });




    $('#form-slide-audio-edit #order').inputNumberFormat({decimal: 0});

    $('#form-slide-audio-edit #file').fileinput({
        theme: 'fa',
        language: 'es',
        showUpload: false,
        dropZoneEnabled: false,
        maxFileCount: 1,
        allowedFileExtensions: ['wav', 'mp3'],
        msgPlaceholder: 'Audios de extensión wav y mp3',
    });




    $('#form-slide-quizz-add #order').inputNumberFormat({decimal: 0});




    $('#form-slide-quizz-edit #order').inputNumberFormat({decimal: 0});

  


    




    CKEDITOR.replace('description_add', {
        toolbar: [
                    { name: 'editing', items: ['Scayt'] },
                    { name: 'links', items: ['Link', 'Unlink'] },
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
                    '/',
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
                    { name: 'styles', items: ['Styles', 'Format'] },
                    { name: 'tools', items: ['Maximize'] }
                ],
                removePlugins: 'elementspath,Anchor',
                heigth: 100
    });
    CKEDITOR.replace('description_edit',{
        toolbar: [
                    { name: 'editing', items: ['Scayt'] },
                    { name: 'links', items: ['Link', 'Unlink'] },
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
                    '/',
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
                    { name: 'styles', items: ['Styles', 'Format'] },
                    { name: 'tools', items: ['Maximize'] }
                ],
                removePlugins: 'elementspath,Anchor',
                heigth: 100
    });


   $('body').on('click', '.btn-view-image', function(e) {
        e.preventDefault();

        $('#company-microlearning-view-image-box').modal('show');

        $('#image-view').attr('src', $(this).data('href'));

        return false;
    });


    $('body').on('click', '.btn-play-video', function(e) {
        e.preventDefault();

        $('#microlearning-play-video').attr('src', $(this).data('href'));
        $('#company-microlearning-play-video-box').modal('show');
        
        return false;
    });

    $('body').on('click', '.btn-play-audio', function(e) {
        e.preventDefault();


        $('#microlearning-play-audio').attr('src', $(this).data('href'));
        $('#company-microlearning-play-audio-box').modal('show');
        
        return false;
    });

    $('body').on('click', '.btn-view-document', function(e) {
        e.preventDefault();


        $('#document-view').attr('src', $(this).data('href'));
        $('#company-microlearning-view-document-box').modal('show');
        
        return false;
    });

    $('body').on('click', '.btn-view-text', function(e) {
        e.preventDefault();

        var url = $(this).data('href');     
        $.ajax({
            'dataType'  : 'json',
            'accept'    : 'application/json',
            'method'    : 'get',
            'url'       :  url,
        }).done(function(response) {
            if(response['success']) {
                $('#document-text').html( response['data']  );
            }

        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });

        
        $('#company-microlearning-view-text-box').modal('show');
        
        return false;
    });



    $('#form-filter #topic_uuid').change(function(e) {
        e.preventDefault();

        $('#form-filter #capsule_uuid').empty();
        gridTable.api().ajax.reload(null, false);
    })


    $('#form-filter #capsule_uuid').change(function(e) {
        e.preventDefault();

        gridTable.api().ajax.reload(null, false);
    })

    $('button.btn-add').click(function(e) {
        e.preventDefault()

        $('#company-microlearning-add-capsule-type-box').modal('show');
        
    } );



    $('body').on('click', 'button.btn-refresh', function(e) {
        e.preventDefault();
        gridTable.api().ajax.reload(null, false);
    });

        /*Script del editor (Aqui comienza el cielo y la tierra) */
                var imagenServidorNoticia;
                var scroll_altura,viente;
                var nombre_user = $(".perfil_u_nombre").text();
                var primer_nombre = nombre_user.split(" ")[0];
                var nuevoHtmlImagen='<div class="articulo_noticia animated fadeIn"> <div class="pasos"> <div class="titulo_pasos animated fadeInDown delay-04 fast">LABEL_STEP_1</div><div class="paso_opcion"> <div class="responsing_cut"> <div class="icon_cut"><span class="fa fa-scissors"></span></div><div class="contenido_cut"> <div class="animated fadeInRight delay-04 fast"> <div> <div class="titulo_cut"> <div>LABEL_CUT</div><div class="fa fa-times" id="cerrar_cut_modal"></div></div><div class="opcion_editor recortar10"> <div class="recortar_texto">LABEL_CUT</div><div id="blockCelda"><span class="fa fa-unlock"></span></div></div></div></div></div></div><div class="responsing_text"> <div class="icon_text"><span class="fa fa-text-width"></span></div><div class="contenido_text"> <div class="animated fadeInRight delay-04 fast"> <div class="texto"> <div class="titulo_text"> <div>LABEL_TEXT</div><div class="fa fa-times" id="cerrar_text_modal"></div></div><div class="fonts mb-20"><select name="fuentes" id="selectFuente" class="select-custom mr-2"><option value="arial" selected>LABEL_FONT_ARIAL</option><option value="calibri">LABEL_FONT_CALIBRI</option><option value="forte">LABEL_FONT_FORTE</option><option value="impact">LABEL_FONT_IMPACT</option><option value="jokerman">LABEL_FONT_JOKERMAN</option><option value="mv boli">LABEL_FONT_MV_BOLI</option><option value="times new roman">LABEL_FONT_TIMES_NEW_ROMAN</option><option value="verdana">LABEL_FONT_VERDANA</option><option value="vivaldi">LABEL_FONT_VIVALDI</option></select><input type="number" class="" data-tooltip="Tamaño de la letra" name="" id="font-size" max="500" min="1" step="1" value="48"/></div><div class="fonts mb-20"> <div class="font" id="negritas" data-tooltip="Negritas"><i class="fa fa-bold" aria-hidden="true"></i></div><div class="font" id="italic" data-tooltip="Letra Cursiva"><i class="fa fa-italic" aria-hidden="true"></i></div><div class="color_letra font"><label>A</label><input type="color" class="" data-tooltip="Color de la letra" name="" id="color" value="#ffffff"/></div><div class="font fa" data-tooltip="Sombra de la letra" id="shadow">S</div><div class="font" id="rectangulo" data-tooltip="Fondo de la letra"> <div class="rectangulo">F</div></div></div><div class="color_fondo_cuadro mb-20 flex-column" style="display:none"> <div class="w-100 d-flex justify-content-between border-bottom"><label for="colorrect" class="font-weight-normal d-flex align-items-center" style="margin:0 !important">LABEL_COLOR_BACKGROUND: </label><input type="color" name="" id="colorrect" value="#000000" style="width:30px" data-tooltip="Color del fondo" class="mr-2"/></div><div class="d-flex flex-column"><label for="opacidad" class="font-weight-normal mt-2">LABEL_BACKGROUND_TRANSPARENCY</label><input type="range" id="opacidad" max="100" min="1" step="1" value="100" ></div></div><input id="texto_input" type="text" name="texto" placeholder="LABEL_ADD_TEXT_HERE"/> </div></div></div></div><div class="responsing_filtros"> <div class="icon_filter"><span class="fa fa-eyedropper"></span></div><div class="contenido_filter"> <div class="titulo_filtro mb-20"> <div>LABEL_FILTERS</div><div class="fa fa-times" id="cerrar_filter_modal"></div></div><div class="fonts mb-20"> <select name="filtros" id="selectFiltro" class="select-custom"><option class="opcion_editor" value="normal">LABEL_FILTER_NORMAL</option><option class="opcion_editor" value=".5,1.3,1.31,1.33,1.38">LABEL_FILTER_NIGHT</option><option class="opcion_editor" value=".7,1.1,1.64,1.66,1.50">LABEL_FILTER_SAINT_ANA</option><option class="opcion_editor" value=".75,1,1.66,1.60,1.51">LABEL_FILTER_CREAM</option><option class="opcion_editor" value=".7,1.2,1.49,1.49,1.6">LABEL_FILTER_MAGIC</option><option class="opcion_editor" value=".7,1.2,1.60,1.66,1.58">LABEL_FILTER_RELIEF</option><option class="opcion_editor" value=".9,.9,1.45,1.54,1.54">LABEL_FILTER_LIGHT</option><option class="opcion_editor" value="1,1.5,1,1,1">LABEL_FILTER_SATURATION</option><option class="opcion_editor" value=".9,1.3,1,1,1">LABEL_FILTER_RETOUCH</option><option class="opcion_editor" value=".8,1,1.6,1.45,1.49">LABEL_FILTER_ORANGE</option><option class="opcion_editor" value=".8,.75,1.60,1.66,1.58">LABEL_FILTER_WIND</option><option class="opcion_editor" value=".8,.9,1.66,1.43,1.28">LABEL_FILTER_DESERT</option><option class="opcion_editor" value=".85,.75,1.47,1.66,1.54">LABEL_FILTER_FOREST</option><option class="opcion_editor" value=".8,.8,1.71,1.64,1.58">LABEL_FILTER_TOWN</option><option class="opcion_editor" value=".8,1.2,1.24,.99,1">LABEL_FILTER_PINK</option><option class="opcion_editor" value=".9,1.1,1.33,1.19,.91">LABEL_FILTER_HISTORY</option><option class="opcion_editor" value="1,1,gris">LABEL_FILTER_GRAY</option><option class="opcion_editor" value=".8,1.5,gris">LABEL_FILTER_OLD_PICTURE</option><option class="opcion_editor" value=".9,1.2,26,-12,0,2">LABEL_FILTER_CHARMING</option><option class="opcion_editor" value="1.1,1.4,40,12,-6,2">LABEL_FILTER_EMOTION</option><option class="opcion_editor" value=".9,1.32,56,47,17,2">LABEL_FILTER_BEIGE</option><option class="opcion_editor" value=".87,1.19,55,37,23,2">LABEL_FILTER_FINE</option><option class="opcion_editor" value="1.2,.9,67,13,-23,2">LABEL_FILTER_LORD</option><option class="opcion_editor" value="1.2,1.2,35,7,18,2">LABEL_FILTER_70S</option><option class="opcion_editor" value=".92,1.23,-11,11,11,2">LABEL_FILTER_TREE</option><option class="opcion_editor" value=" 1,1.4,-3,-1,-12,2">LABEL_FILTER_SUMMER</option><option class="opcion_editor" value=".85,1.26,-15,2,-1,2">LABEL_FILTER_COLD_WEATHER</option><option class="opcion_editor" value="1,1.4,5,12,1,2">LABEL_FILTER_ANGELS</option><option class="opcion_editor" value=".9,1.2,43,-17,-55,2">LABEL_FILTER_HOT</option><option class="opcion_editor" value="1,1.29,29,26,17,2">LABEL_FILTER_FALL</option><option class="opcion_editor" value=".85,1.3,43,25,-11,2">LABEL_FILTER_MARCH</option><option class="opcion_editor" value=".8,1.25,31,41,12,2">LABEL_FILTER_PEAR</option><option class="opcion_editor" value="1,1.36,4,5,1,2">LABEL_FILTER_COMMON</option><option class="opcion_editor" value=".9,1.3,37,-25,1,2">LABEL_FILTER_GOLD</option><option class="opcion_editor" value="1.1,1.3,-47,-42,-30,2">LABEL_FILTER_GOTHIC</option><option class="opcion_editor" value="1,1.4,-5,42,11,2">LABEL_FILTER_FORESTRY</option><option class="opcion_editor" value=".9,1.2,-5,-7,4,2">LABEL_FILTER_MOON</option><option class="opcion_editor" value="1.1,1.3,-1,-1,26,2">LABEL_FILTER_PARTY</option> </select> </div></div></div><div class="volver"><span class="icon-undo"></span>LABEL_START_OVER</div><div class="paso_1 paso animated bounceInDown delay-04 fast">1</div><div class="paso_2 a1 animated bounceInDown delay-06 fast">2</div><div class="paso_2 b1 animated bounceInDown delay-08 fast">3</div></div></div><div class="editor_imagenes"> <div class="fondo_oscuro"></div><div class="editor_imagenes2 "> <div> <div class="canvas_imagen"> <div class="canvas recortar"> <div class="canvas_subir d-flex flex-column" id="imagen_noticia"><div>LABEL_DRAG_IMAGE_HERE_OR </div><label class="font-weight-normal mt-2" style="font-size:0.6em"for="imagen_noticia_file"> LABEL_UPLOAD_FILE_IMAGE <div class="ml-2 btn btn-primary btn-sm">LABEL_SELECT_IMAGE</div></label> <input style="display:none" type="file" id="imagen_noticia_file" accept="image/x-png,image/jpeg"></div></div></div><div class="botones_dimenciones"> <div class="scale"> <div class="dimenciones"> <div id="ancho">1240px</div><div>x</div><div id="alto">720px</div></div><div class="porciento"> <div id="menos_scale"><span class="icon-minus fa fa-minus"></span></div><div class="ps"> <ul class="cantidades_scale"> <li data-scale="2" class="as">200%</li><li data-scale="1" class="as">100%</li><li data-scale="0.75" class="as">75%</li><li data-scale="0.5" class="as">50%</li><li data-scale="0.25" class="as">25%</li></ul> <div id="porciento_scale">50%</div></div><div id="mas_scale"><span class="icon-plus fa fa-plus"></span></div></div></div><div class="botones"><button class="boton_normal" id="ir_atras">LABEL_GO_BACK</button><button class="boton_normal" id="boton_recortar">LABEL_DATATABLE_SNEXT</button></div></div></div><div class="modificar animated fadeInRight delay-04 fast escalar"> <div> <div class="titulo_recortar"><span class="icon-ungroup fa fa-scissors mb-20"></span>LABEL_CUT</div><div class="opcion_editor recortar10"> <div class="recortar_texto">LABEL_CUT</div><div id="blockCelda"><span class="fa fa-unlock"></span></div></div></div><div class="texto"> <div class="mb-20"> <div class="titulo_texto "><span class="icon-plus fa fa-text-width"></span>LABEL_TEXT</div></div><div class="fonts mb-20"> <select name="fuentes" id="selectFuente" class="select-custom mr-2"> <option value="arial" selected>LABEL_FONT_ARIAL</option> <option value="calibri">LABEL_FONT_CALIBRI</option> <option value="forte">LABEL_FONT_FORTE</option> <option value="impact">LABEL_FONT_IMPACT</option> <option value="jokerman">LABEL_FONT_JOKERMAN</option> <option value="mv boli">LABEL_FONT_MV_BOLI</option> <option value="times new roman">LABEL_FONT_TIMES_NEW_ROMAN</option> <option value="verdana">LABEL_FONT_VERDANA</option> <option value="vivaldi">LABEL_FONT_VIVALDI</option> </select> <input type="number" class="" data-tooltip="Tamaño de la letra" name="" id="font-size" max="500" min="1" step="1" value="48"/> </div><div class="fonts mb-20"> <div class="font" id="negritas" data-tooltip="Negritas"><i class="fa fa-bold" aria-hidden="true"></i></div><div class="font" id="italic" data-tooltip="Letra Cursiva"><i class="fa fa-italic" aria-hidden="true"></i></div><div class="color_letra font"><label>A</label><input type="color" class="" data-tooltip="Color de la letra" name="" id="color" value="#ffffff"/></div><div class="font fa" data-tooltip="Sombra de la letra" id="shadow">S</div><div class="font" id="rectangulo" data-tooltip="Fondo de la letra"> <div class="rectangulo">F</div></div></div><div class="color_fondo_cuadro mb-20 flex-column" style="display:none"> <div class="w-100 d-flex justify-content-between border-bottom"><label for="colorrect" class="font-weight-normal d-flex align-items-center" style="margin:0 !important">LABEL_COLOR_BACKGROUND: </label><input type="color" name="" id="colorrect" value="#000000" style="width:30px" data-tooltip="Color del fondo" class="mr-2"/></div><div class="d-flex flex-column"><label for="opacidad" class="font-weight-normal mt-2">LABEL_BACKGROUND_TRANSPARENCY</label><input type="range" id="opacidad" max="100" min="1" step="1" value="100" ></div></div><input id="texto_input" type="text" name="texto" placeholder="LABEL_ADD_TEXT_HERE"/> <div class="mb-20"> <div class="titulo_filtro"><span class="icon-eyedropper fa fa-eyedropper"></span>LABEL_FILTERS</div></div><div class="fonts mb-20"> <select name="filtros" id="selectFiltro" class="select-custom selectFiltro"><option class="opcion_editor" value="normal" >LABEL_FILTER_NORMAL</option><option class="opcion_editor" value=".5,1.3,1.31,1.33,1.38">LABEL_FILTER_NIGHT</option><option class="opcion_editor" value=".7,1.1,1.64,1.66,1.50">LABEL_FILTER_SAINT_ANA</option><option class="opcion_editor" value=".75,1,1.66,1.60,1.51">LABEL_FILTER_CREAM</option><option class="opcion_editor" value=".7,1.2,1.49,1.49,1.6">LABEL_FILTER_MAGIC</option><option class="opcion_editor" value=".7,1.2,1.60,1.66,1.58">LABEL_FILTER_RELIEF</option><option class="opcion_editor" value=".9,.9,1.45,1.54,1.54">LABEL_FILTER_LIGHT</option><option class="opcion_editor" value="1,1.5,1,1,1">LABEL_FILTER_SATURATION</option><option class="opcion_editor" value=".9,1.3,1,1,1">LABEL_FILTER_RETOUCH</option><option class="opcion_editor" value=".8,1,1.6,1.45,1.49">LABEL_FILTER_ORANGE</option><option class="opcion_editor" value=".8,.75,1.60,1.66,1.58">LABEL_FILTER_WIND</option><option class="opcion_editor" value=".8,.9,1.66,1.43,1.28">LABEL_FILTER_DESERT</option><option class="opcion_editor" value=".85,.75,1.47,1.66,1.54">LABEL_FILTER_FOREST</option><option class="opcion_editor" value=".8,.8,1.71,1.64,1.58">LABEL_FILTER_TOWN</option><option class="opcion_editor" value=".8,1.2,1.24,.99,1">LABEL_FILTER_PINK</option><option class="opcion_editor" value=".9,1.1,1.33,1.19,.91">LABEL_FILTER_HISTORY</option><option class="opcion_editor" value="1,1,gris">LABEL_FILTER_GRAY</option><option class="opcion_editor" value=".8,1.5,gris">LABEL_FILTER_OLD_PICTURE</option><option class="opcion_editor" value=".9,1.2,26,-12,0,2">LABEL_FILTER_CHARMING</option><option class="opcion_editor" value="1.1,1.4,40,12,-6,2">LABEL_FILTER_EMOTION</option><option class="opcion_editor" value=".9,1.32,56,47,17,2">LABEL_FILTER_BEIGE</option><option class="opcion_editor" value=".87,1.19,55,37,23,2">LABEL_FILTER_FINE</option><option class="opcion_editor" value="1.2,.9,67,13,-23,2">LABEL_FILTER_LORD</option><option class="opcion_editor" value="1.2,1.2,35,7,18,2">LABEL_FILTER_70S</option><option class="opcion_editor" value=".92,1.23,-11,11,11,2">LABEL_FILTER_TREE</option><option class="opcion_editor" value=" 1,1.4,-3,-1,-12,2">LABEL_FILTER_SUMMER</option><option class="opcion_editor" value=".85,1.26,-15,2,-1,2">LABEL_FILTER_COLD_WEATHER</option><option class="opcion_editor" value="1,1.4,5,12,1,2">LABEL_FILTER_ANGELS</option><option class="opcion_editor" value=".9,1.2,43,-17,-55,2">LABEL_FILTER_HOT</option><option class="opcion_editor" value="1,1.29,29,26,17,2">LABEL_FILTER_FALL</option><option class="opcion_editor" value=".85,1.3,43,25,-11,2">LABEL_FILTER_MARCH</option><option class="opcion_editor" value=".8,1.25,31,41,12,2">LABEL_FILTER_PEAR</option><option class="opcion_editor" value="1,1.36,4,5,1,2">LABEL_FILTER_COMMON</option><option class="opcion_editor" value=".9,1.3,37,-25,1,2">LABEL_FILTER_GOLD</option><option class="opcion_editor" value="1.1,1.3,-47,-42,-30,2">LABEL_FILTER_GOTHIC</option><option class="opcion_editor" value="1,1.4,-5,42,11,2">LABEL_FILTER_FORESTRY</option><option class="opcion_editor" value=".9,1.2,-5,-7,4,2">LABEL_FILTER_MOON</option><option class="opcion_editor" value="1.1,1.3,-1,-1,26,2">LABEL_FILTER_PARTY</option> </select> </div></div></div></div></div></div><dav class="fixed_noticia"></dav><dav class="cuadro_noticias animated bounceInUp delay-04" id="cuadro_noticias"> <dav class="relative"> <div class="titulo_topico">LABEL_TITLE_TOPIC</div><canvas class="imagen_noticias" id="imagen_noticias" width="320" height="480"></canvas> </dav> <div class="progreso d-flex align-items-center justify-content-between"><progress value="0" max="100"></progress><span class="ml-2">0.0%</span></div></dav>'
                
                $(document).on("click", ".info_noticia", function(e){
                        imagenServidorNoticia = elemento.toDataURL("image/jpeg", 1.0);
                        $('.background').val(imagenServidorNoticia.split(',')[1]);
            $('.imageType .file').val(imagenServidorNoticia.split(',')[1]);
                        $(".c1").addClass("paso");

                
                })

                function iniciarEditor(campo, image=''){
                 cortar=false;
                recorte_listo=false;
                texto="";
                seis=true;
                color="#ffffff";
                texto_listo=false,siete=false;
                uno=true;
                size=48;
        blockCelda=false;
                cinco=true;
                xf=320,yf =480;
                negritas=false, bold="";
                shadow = true, nueve=true;
                italic=false, ita="";
                rectangulo=false, diez=false;
        fontfamily="Arial";
        r=0,g=0,b=0,a=1;
                window.clearInterval(editorNoticia);    
                setTimeout(function(){
                        scroll_altura=$(".articulo_noticia").offset().top-110;
                        anchoFondoOscuro = $(".articulo_noticia").width();
                        altoFondoOscuro = $(".editor_imagenes").height();
                        $(".fondo_oscuro").css("width",""+anchoFondoOscuro+"px");
                        $(".fondo_oscuro").css("height",""+altoFondoOscuro+"px");
                
                },navegacion(nuevoHtmlImagen,campo,image));

                }
        var edit;
                $(document).on("click", ".volver", function(){
                var nombre_user = $(".perfil_u_nombre").text();
                var primer_nombre = nombre_user.split(" ")[0];
                 cortar=false;
         blockCelda=false;
                cinco=true;
                recorte_listo=false;
                texto="";
                seis=true;
                color="#ffffff";
                texto_listo=false,siete=false;
                uno=true;
                size=48;
        edit=false;
                xf=320,yf =480;
                negritas=false, bold="";
                shadow = true, nueve=true;
                italic=false, ita="";
                rectangulo=false, diez=false;
        fontfamily="Arial";
        r=0,g=0,b=0,a=1;
                 var imagenServidorNoticia;
         console.log(seleccionarCampo)
                window.clearInterval(editorNoticia);
                setTimeout(function(){
                        scroll_altura=$(".articulo_noticia").offset().top-110;
                        anchoFondoOscuro = $(".articulo_noticia").width();
                        altoFondoOscuro = $(".editor_imagenes").height();
                        $(".fondo_oscuro").css("width",""+anchoFondoOscuro+"px");
                        $(".fondo_oscuro").css("height",""+altoFondoOscuro+"px");
                
                },navegacion(nuevoHtmlImagen,seleccionarCampo));
                
                })
       
                function navegacion(nuevoHtmlImagen,campo,image='',reload=true){
                selectorElementoName=campo.find('#name')

                selectorElementoEditor=campo.find('#contenido');
                                edit=true;
                                if(image!=''){
                    edit=false;
                                        const getBase64FromUrl = async (url) => {
                                                const data = await fetch(url);
                                                const blob = await data.blob();
                                                return new Promise((resolve) => {
                                                        const reader = new FileReader();
                                                        reader.readAsDataURL(blob); 
                                                        reader.onloadend = function() {
                                                        const base64data = reader.result;   
                                                        resolve(base64data);
                                                        }
                                                });
                                        }

                                        getBase64FromUrl(image).then(function(e){       
                                                selectorElementoName.trigger('change');
                                                $(".volver").css("display","block")
                                                $(".a1").addClass("paso");
                                                $(".titulo_pasos").html("LABEL_STEP_2");
                                                setTimeout(function(){
                                                        recorte_listo=true;
                                                        $(".fondo_oscuro").css("display","none");
                                                        $("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
                                                        $(".recortar10").removeClass("recortar");
                                                        $(".canvas").removeClass("recortar");
                                                        $(".b1").addClass("paso");
                                                        $(".titulo_pasos").html("LABEL_STEP_3");
                                                        if(texto!=""){
                                                                seis=true;
                                                                siete=true;
                                                        }
                                                        cinco=true;
                                                        dos=true;
                                                        cuatro=true;
                                                        actualizar();
                                        
                                                },editorNoticia(e));
                                                
                                                
                                        })
                
                                        setTimeout(function(){                          
                                                $(".canvas_subir").html('<span class="icon-plus fa fa-spinner"></span> Cargando...')
                                                selectorElementoName.trigger('change');
                                        },selectorElementoEditor.html(nuevoHtmlImagen));
                                }else{
                                        setTimeout(function(){                          
                                            selectorElementoName.trigger('change');
                                        },selectorElementoEditor.html(nuevoHtmlImagen));
                                }
                        
                }

                $(window).on("scroll", function(){
                        console.log(scroll_altura)
                if($(window).scrollTop()>scroll_altura){
                        $("#cuadro_noticias").addClass("fixed");
                }else{
                        $("#cuadro_noticias").removeClass("fixed");
                }
        })
        $(window).resize(function() { 
                anchoFondoOscuro = $(".articulo_noticia").width();
                altoFondoOscuro = $(".editor_imagenes").height();
                $(".fondo_oscuro").css("width",""+anchoFondoOscuro+"px");
                $(".fondo_oscuro").css("height",""+altoFondoOscuro+"px");
                setTimeout(function(){
                        anchoFondoOscuro = $(".articulo_noticia").width();
                        altoFondoOscuro = $(".editor_imagenes").height();
                        $(".fondo_oscuro").css("width",""+anchoFondoOscuro+"px");
                        $(".fondo_oscuro").css("height",""+altoFondoOscuro+"px");
                },300)
                
        });
        $(document).on("dragover", "#imagen_noticia", function(e){
                e.preventDefault();
                e.stopPropagation();
                $(this).css({"background":"rgba(0,0,0,.2)"})
        })
        $(document).on("drop", "#imagen_noticia", function(e){
                e.preventDefault();
                e.stopPropagation();
                $(this).css("background", "none");
                var archivo = e.originalEvent.dataTransfer.files;
                var img=archivo[0];
                if(img.type =="image/jpeg"||img.type =="image/png"){
                        $(".modificar").removeClass("animated");
                        var render = new FileReader();
                        render.readAsDataURL(img);
                        render.onload = function(e){
                                imagen2=new Image();
                                imagen2.src=e.target.result;
                                
                                $(imagen2).ready(function(e){
                                        if(imagen2.width<320||imagen2.height<480){
                                                $.fn.showError('LABEL_MINIMUM_IMAGE_SIZE');
                                        }else{
                                                $(".volver").css("display","block")
                                                $(".a1").addClass("paso");
                                                $(".titulo_pasos").html("LABEL_STEP_2");
                                                editorNoticia(imagen2.src)
                                        }                       
                                })
                        }
                }else{
                        $.fn.showError('LABEL_SUPPORTED_FORMATS');
                }
        })      
    $(document).on("change", "#imagen_noticia_file", function(e){
                file = $(this)[0].files[0];
                e.preventDefault();
                $(this).css("background", "none");
                var archivo = file;
                var img=file;
                if(img.type =="image/jpeg"||img.type =="image/png"){
                        $(".modificar").removeClass("animated");
                        var render = new FileReader();
                        render.readAsDataURL(img);
                        render.onload = function(e){
                                imagen2=new Image();
                                imagen2.src=e.target.result;
                                
                                $(imagen2).ready(function(e){
                                        if(imagen2.width<320||imagen2.height<480){
                                                $.fn.showError('LABEL_MINIMUM_IMAGE_SIZE');
                                        }else{
                                                $(".volver").css("display","block")
                                                $(".a1").addClass("paso");
                                                $(".titulo_pasos").html("LABEL_STEP_2");
                                                editorNoticia(imagen2.src)
                                        }                       
                                })
                        }
                }else{
                        $.fn.showError('LABEL_SUPPORTED_FORMATS');
                }
        })      
        $(document).on("dragover", "body", function(e){
                e.preventDefault();
                e.stopPropagation();
        })
        $(document).on("drop", "body", function(e){
                e.preventDefault();
                e.stopPropagation();
        })      

        var canvas='<div class="editorNoticia"><canvas id="editorNoticia">LABEL_NOT_SUPPORTED</canvas></div>';
        $(document).on("mouseover", ".editorNoticia", function(){
        const getScrollBarWidth = () => window.innerWidth - document.documentElement.getBoundingClientRect().width
                let anchoScroll= getScrollBarWidth()+"px";
                $("body").css({"overflow": "hidden"});
                $(".cuadro_noticias, .fixed_noticia,.tituloEditor,.grid-padre,.subpanel").css("margin-right",anchoScroll )
                $(".barra,.footer").css("padding-right",anchoScroll)
                
                

        })
        $(document).on("mouseover", "#editorNoticia", function(){
                if(recorte_listo){
                        ocho=true;      
                }
        })
        $(document).on("mouseout", "#editorNoticia", function(){
                if(recorte_listo){
                        ocho=false;
                        actualizar2()
                }
        })
        $(document).on("mouseout", ".editorNoticia",function(){
                $("body").css({"overflow": "auto"})
                $(".cuadro_noticias, .fixed_noticia,.tituloEditor,.grid-padre").css("margin-right", "0px")
                $(".barra,.footer").css("padding-right","0px")
                
        })
        $(document).on('mousewheel', ".editorNoticia",function(e){
                var ruedita = e.originalEvent.wheelDelta 
                if(ruedita>0){
                        scale = scale+(scale/10); 
                        $("#porciento_scale").html((scale*100).toFixed(2)+"%")
                }else{
                        scale = scale-(scale/10); 
                        $("#porciento_scale").html((scale*100).toFixed(2)+"%")
                }
                $("#editorNoticia").css({"transform": "scale("+scale+")"});
        })
        $(document).on("click", ".as", function(e){
                e.preventDefault();
                 scale = $(this).data("scale");
                 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
                 $("#editorNoticia").css({"transform": "scale("+scale+")"});
                
        })
        $(document).on("click", ".ps", function(e){
                e.preventDefault();
                $(".cantidades_scale").slideToggle(200).css("display", "block");
        })
        $(document).on("click", "#cerrar_filter_modal, .icon_filter", function(e){
                e.preventDefault();
                if(recorte_listo){
                $(".contenido_filter").slideToggle(200).css("display", "block");
                }
        })
        $(document).on("click", "#cerrar_text_modal, .icon_text", function(e){
                e.preventDefault();
                if(recorte_listo){
                        $(".contenido_text").slideToggle(200).css("display", "block");
                }
        })
        
        $(document).on("click", "#cerrar_cut_modal, .icon_cut", function(e){
                e.preventDefault();
                if(cortar){
                        $(".contenido_cut").slideToggle(200).css("display", "block");
                }
                
        })
        $(document).on("click", "#menos_scale", function(e){
                e.preventDefault();
                scale = scale-(scale/10);
                 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
                 $("#editorNoticia").css({"transform": "scale("+scale+")"});
        })

        $(document).on("click", "#mas_scale", function(e){
                e.preventDefault();
                scale = scale+(scale/10);
                 $("#porciento_scale").html((scale*100).toFixed(2)+"%")
                 $("#editorNoticia").css({"transform": "scale("+scale+")"});
        })
        $(document).on('change', '#selectFiltro', function(e){
                
                data=$(this).val()
                if(data=="normal"){
                        filter();
                }else{
                        data=data.split(',');
                        if(data[2]=='gris'){    
                                filtergris(data[0],data[1]);
                        }else{  
                                filter(Number(data[0]),Number(data[1]),Number(data[2]),Number(data[3]),Number(data[4]),Number(data[5]));
                        }
                }
        })
        var texto_listo=false,siete=false;
        var texto;
        $(document).on("keyup", "#texto_input", function(e){
                e.preventDefault();
                texto = $(this).val();
                if(texto_actualizar){
                        siete=true;     
                }
                if(texto!=""){
                        texto_actualizar=true;
                        actualizar2();
                }else{
                        actualizar2();
                }

        })
        var color="#ffffff";
        $(document).on("change input", "#color", function(){
        color=$(this).val();
        seis=true;
        actualizar2();
    })
    $(document).on("keypress", "#font-size, #texto_input", function(e){
        if(e.which == 13){
                return false;
        }
        });
    var size=48;
    $(document).on("keyup change", "#font-size", function(){
        size=$(this).val();
        size = parseInt(size);
        seis=true;
        siete=true;
        actualizar2();
    })
    var negritas=false, bold="";
    $(document).on("click", "#negritas", function(e){
        e.preventDefault();
        if(!negritas){
                bold="bold";
                $(this).addClass("fa");
                seis=true;
                siete=true;
                actualizar2();
                negritas=true;
        }else{
                bold="";
                $(this).removeClass("fa");
                seis=true;
                siete=true;
                actualizar2();
                negritas=false;
        }
    })
    var italic=false, ita="";
     $(document).on("click", "#italic", function(e){
        e.preventDefault();
        if(!italic){
                ita="italic";
                $(this).addClass("fa");
                seis=true;
                siete=true;
                actualizar2();
                italic=true;
        }else{
                ita="";
                $(this).removeClass("fa");
                seis=true;
                siete=true;
                actualizar2();
                italic=false;
        }
    })
    var fontfamily="Arial";
     $(document).on("change", "#selectFuente", function(e){
        e.preventDefault();
        fontfamily= $(this).val();
        seis=true;
        siete=true;
        actualizar2();
        
    })
     var shadow = true, nueve=true;
     $(document).on("click","#shadow", function(e){
        e.preventDefault();
        if(shadow){
                $(this).removeClass("fa");
                seis=true;
                nueve=false;
                actualizar2();
                shadow=false;
        }else{
                $(this).addClass("fa");
                seis=true;
                nueve=true;
                actualizar2();
                shadow=true;
        }

     })
     var rectangulo=false, diez=false, colorrect="#000000";
     $(document).on("click", "#rectangulo", function(e){
        e.preventDefault();
        if(!rectangulo){
                $(this).addClass("fa");
                        $('.color_fondo_cuadro').css('display','flex')
                diez=true;
                actualizar2();
                rectangulo=true;
        }else{
                $(this).removeClass("fa");
                         $('.color_fondo_cuadro').css('display','none')
                diez=false;
                actualizar2();
                rectangulo=false;
        }

     })
     var r=0,g=0,b=0;
     $(document).on("change input", "#colorrect", function(){
        colorrect=$(this).val();
        r=parseInt(colorrect.slice(1,3),16);
        g=parseInt(colorrect.slice(3,5),16);
        b=parseInt(colorrect.slice(5,7),16);
        seis=true;
        actualizar2();
    })
    var a=1;
        
    $(document).on("mousemove change ", "#opacidad", function(){
        a=$(this).val();
        a=a/100;
        seis=true;
        actualizar2();
    })
        var imaNoti = new Image();
        function filter(brillo=1, contraste=1, rojo=1, verde=1, azul=1, valor=1){
                cuatro=false;
                restaurar(brillo, contraste);
                datos=imagenOriginal.data;
                if(valor==2){
                        for (var i =  0; i <datos.length; i+=4) {
                                datos[i]=datos[i]+rojo;
                                datos[i+1]=datos[i+1]+verde;
                                datos[i+2]=datos[i+2]+azul;
                        }
                }else{
                        for (var i =  0; i <datos.length; i+=4) {
                                datos[i]=datos[i]*rojo;
                                datos[i+1]=datos[i+1]*verde;
                                datos[i+2]=datos[i+2]*azul
                        }       
                }
                editor.putImageData(imagenOriginal,0,0)
                var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
            imaNoti.src = imagenNoticia;
                actualizar2();
        }
        function filtergris(brillo=1, contraste=1){
                cuatro=false;
                restaurar(brillo, contraste);
                datos=imagenOriginal.data;
                var auxiliar;
                for (var i =  0; i <datos.length; i+=4) {
                        auxiliar = 0.34 * datos[i] + 0.5 *datos[i+1] + 0.1/6 * datos[i+2]; 
                        datos[i]=auxiliar;
                        datos[i+1]=auxiliar;
                        datos[i+2]=auxiliar;
                }       
                
                editor.putImageData(imagenOriginal,0,0)
                var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
            imaNoti.src = imagenNoticia;
                actualizar2();
        }
        function restaurar(brillo = 1, contraste=1){
                editor.filter = "none"
                editor.filter = 'contrast('+contraste+') brightness('+brillo+') saturate(1) sepia(0)';
                editor.fillStyle="rgba(255,255,255,1)"
                editor.fillRect(0,0,ancho,alto);
                editor.fillStyle=""+color+"";
                var pxf=0,pyf=0;
                        if(xf>=(yf/recorte)){
                                pxf=xf/ancho;
                                pyf=yf/pxf;
                                py=(alto/2)-(pyf/2);
                                editor.drawImage(imagen,x,y,xf,yf,0,py,ancho,pyf);
                        }else{
                                pyf=yf/alto;
                                pxf=xf/pyf;
                                px=(ancho/2)-(pxf/2);
                                editor.drawImage(imagen,x,y,xf,yf,px,0,pxf,alto);
                        }
                imagenOriginal = editor.getImageData(0,0,ancho,alto)
        }
        var ocho=false;
        function actualizar2(){
                if(recorte_listo){
                if(cuatro){
                        imagenOriginal = editor.getImageData(0,0,ancho,alto)
                        var imagenNoticia = elemento.toDataURL("image/jpeg", 1.0);
                imaNoti.src = imagenNoticia;
                cuatro=false;
                }
                editor.filter = "none"
                $(imaNoti).ready(function(e){   
                        noticia.drawImage(imaNoti,0,0,320,480);
                        editor.drawImage(imaNoti,0,0,ancho,alto)
                        if(texto_actualizar){
                                if(texto!=""){
                                        if(seis){
                                                ancho_imaNoti = imaNoti.width;
                                                
                                                scale_noticia = -(((ancho_imaNoti-320)/ancho_imaNoti)-1);
                                                editor.fillStyle=""+color+"";
                                                editor.strokeStyle="rgb(255,255,255)";
                                                if(nueve){
                                                        editor.shadowColor="rgba(0,0,0,.5)";
                                                        editor.shadowOffsetX=6;
                                                        editor.shadowOffsetY=6;
                                                        editor.shadowBlur=6;
                                                        noticia.shadowColor="rgba(0,0,0,.5)";
                                                        noticia.shadowOffsetX=6*scale_noticia;
                                                        noticia.shadowOffsetY=6*scale_noticia;
                                                        noticia.shadowBlur=6*scale_noticia;
                                                }else{
                                                        editor.shadowColor="rgba(0,0,0,0)";
                                                        noticia.shadowColor="rgba(0,0,0,0)";
                                                }
                                                editor.font=""+ita+" "+bold+" "+size+"px "+fontfamily+"";
                                                editor.textAlign="start";
                                                editor.textBaseline="top";
                
                                                var sizeNoticia = size*scale_noticia;
                                                noticia.fillStyle=""+color+"";
                                                noticia.font=""+ita+" "+bold+" "+sizeNoticia+"px "+fontfamily+"";
                                                noticia.textAlign="start";
                                                noticia.textBaseline="top";
                                                seis=false;
                                        }
                                        if(siete){
                                                dimencionesTexto = editor.measureText(texto);
                                                txf=dimencionesTexto.width+20;
                                                tyf= (20+size); 
                                                siete=false;
                                        }
                                        if(cinco){
                                                dimencionesTexto = editor.measureText(texto);
                                                if(xf>=(yf/recorte)){
                                                        tx=(xf/2)-(dimencionesTexto.width/2);
                                                        ty=(xf*recorte/2)-(size/2);
                                                }else{
                                                        tx=(yf/recorte/2)-(dimencionesTexto.width/2);
                                                        ty=(yf/2)-(size/2);
                                                }
                                                
                                                txf=dimencionesTexto.width+20;
                                                tyf= size+20;   
                                                cinco=false;
                                        }
                                        if(diez){
                                                editor.fillStyle="rgba("+r+","+g+","+b+","+a+")";
                                                noticia.fillStyle="rgba("+r+","+g+","+b+","+a+")";
                                                editor.fillRect(tx-10,ty-10,txf,tyf);
                                                noticia.fillRect(((tx-10)*scale_noticia),((ty-10)*scale_noticia),txf*scale_noticia,tyf*scale_noticia);
                                                editor.fillStyle=""+color+"";
                                                noticia.fillStyle=""+color+"";

                                        }
                                        editor.fillText(texto,tx,ty);
                                        noticia.fillText(texto,(tx*scale_noticia),ty*scale_noticia);
                                        if(ocho){
                                                editor.strokeRect(tx-10,ty-10,txf,tyf)
                                                editor.arc(tx+txf,ty+tyf,10,0,Math.PI*2,false);
                                                editor.fill();
                                                editor.beginPath();
                                        }
                                        texto_listo=true;
                                }
                        }
                })
                
        }
        }
        function actualizar(){
                        $(imagen).ready(function(e){
                                if(uno){
                                        ancho=imagen.width, alto = imagen.height;
                                        elemento.width = ancho;
                                        elemento.height = alto;
                                        $(".scale").css("display","flex");
                                        if(ancho<=alto){
                                         scale = -(((alto-450)/alto)-1);
                                        
                                        
                                        }else{                                  
                                         scale = -(((ancho-500)/ancho)-1);
                                
                                        }
                    scale=scale*0.80;
                                        if(edit){
                                                if((ancho*recorte)<=alto){
                                                        xf=ancho*.70;
                                                        yf=xf*recorte;
                                                }else{
                                                        yf=alto*.70;
                                                        xf=yf/recorte;
                                                }
                                        }
                                        cuadro_dimencion=Math.round(12/scale);
                                        
                                        if(xf<50||yf<50){
                                                xf=50;
                                                yf=xf*recorte;
                                        }
                                        mitadX=ancho/2;
                                        mitadY=alto/2;
                                        x=mitadX-xf/2;
                                        y=mitadY-yf/2;
                                        
                                        $("#porciento_scale").html((scale*100).toFixed(2)+"%")
                                        $("#ancho").html(ancho+"px");
                                        $("#alto").html(alto+"px");
                                        uno=false;
                                }
                                if(dos){
                                        
                                        if(xf>=(yf/recorte)){
                                                alto=xf*recorte;
                                                ancho=xf;
                                        }else{
                                                ancho=yf/recorte;
                                                alto=yf;

                                        }
                                        elemento.width = ancho;
                                        elemento.height = alto;
                                        if(xf<=yf){
                                         scale = -(((yf-450)/yf)-1);
                                         
                                        }else{                                  
                                         scale = -(((xf-500)/xf)-1);
                                        }
                                        
                                        $("#porciento_scale").html((scale*100).toFixed(2)+"%")
                                        $("#ancho").html(Math.round(xf)+"px");
                                        $("#alto").html(Math.round(yf)+"px");
                                        dos=false;
                                }

                                        var pxf=0,pyf=0;
                                        noticia.fillStyle="rgba(255,255,255,1)"
                                        noticia.fillRect(0,0,320,480);
                                if(xf>=(yf/recorte)){
                                        pxf=xf/320;
                                        pyf=yf/pxf;
                                        py=(480/2)-(pyf/2);
                                        noticia.drawImage(imagen,x,y,xf,yf,0,py,320,pyf);
                                }else{
                                        pyf=yf/480;
                                        pxf=xf/pyf;
                                        px=(320/2)-(pxf/2);
                                        noticia.drawImage(imagen,x,y,xf,yf,px,0,pxf,480);
                                }
                                
                                $("#editorNoticia").css({"transform": "scale("+scale+")"});
                                if(!recorte_listo){
                                        editor.drawImage(imagen,0,0,ancho,alto);
                                        editor.fillStyle="rgba(0,0,0,.2)"
                                        editor.fillRect(0,0,ancho,alto);
                                        editor.fillStyle="rgba(255,255,255,.2)"
                                        editor.fillRect(x,y,xf,yf);
                                        editor.fillStyle="rgba(255,255,255,0.8)"
                                        editor.fillRect(x,y,cuadro_dimencion,cuadro_dimencion);
                                        editor.fillRect((x+xf)-cuadro_dimencion,y,cuadro_dimencion,cuadro_dimencion);
                                        editor.fillRect(x,y+yf-cuadro_dimencion,cuadro_dimencion,cuadro_dimencion);
                                        editor.fillRect(x+xf-cuadro_dimencion,yf+y-cuadro_dimencion,cuadro_dimencion,cuadro_dimencion);
                                        esta=true;
                                }else{
                                        var pxf=0,pyf=0;
                                        
                                        editor.fillStyle="rgba(255,255,255,1)"
                                        editor.fillRect(0,0,ancho,alto);
                                        if(xf>=(yf/recorte)){
                                                pxf=xf/ancho;
                                                pyf=yf/pxf;
                                                py=(alto/2)-(pyf/2);
                                                editor.drawImage(imagen,x,y,xf,yf,0,py,ancho,pyf);
                                        }else{
                                                pyf=yf/alto;
                                                pxf=xf/pyf;
                                                px=(ancho/2)-(pxf/2);
                                                editor.drawImage(imagen,x,y,xf,yf,px,0,pxf,alto);
                                }
                                        
                                }
                        })
                }
        var imagenOriginal;
        var x,y,xf=320,yf =480, elemento,editor,centro, total,scale,dimencionesTexto,ancho_imaNoti,
        recorte_listo=false,alto,ancho,tx,ty,txf,tyf,cuatro=true,texto_actualizar=false,cinco=true,seis=true,cuatro;
        var  mitadY,mitadX, uno=true,dos=false, recorte=480/320, imagen_noticias, scale_noticia, tres=true,rotar=false, cortar=false;;
        var translateX, cuadro_dimencion;
                
        $(document).on("click", ".recortar10", function(e){
                
                e.preventDefault();
                recorte_listo=false;
                uno=true;
                $(".fondo_oscuro").css("display","block");
                $("#boton_recortar").addClass("recortar").text("Recortar").removeClass("info_noticia");
                $("#boton_recortar3").addClass("recortar").text("Recortar").removeClass("info_noticia3");
                $(".contenido_text").css("display", "none");
                $(".contenido_filter").css("display", "none");
                $(".recortar10").addClass("recortar");
                $(".canvas").addClass("recortar")
                $(".oa").removeClass("oa");
                $("#normal").addClass("oa");
                $(".b1").removeClass("paso");
                $(".titulo_pasos").html("LABEL_STEP_2");
                window.clearInterval(actualizar2);
                actualizar();

        })

        
        blockCelda=true;
        $(document).on("click", "#blockCelda", function(e){
                e.preventDefault();
                if(blockCelda){
                        $(this).html('<span class="fa fa-unlock"></span>')
                        
                        blockCelda=false;
                }else{
                        $(this).html('<span class="fa fa-lock"></span>')
                        blockCelda=true;
                }
                t4=true;
                
        })
        var imagen 
        function editorNoticia(img){
                 cortar=true;
                imagen= new Image();
                $(".canvas").html(canvas);
                elemento = document.getElementById("editorNoticia");
                editor = elemento.getContext("2d");
                elemento2 = document.getElementById("imagen_noticias");
                noticia = elemento2.getContext("2d");

                $(document).on("click", ".boton_marino.recortar",function(e){
                        e.preventDefault();
                        recorte_listo=true;
                        $(".fondo_oscuro").css("display","none");
                        $("#boton_recortar").removeClass("recortar").text("LABEL_SEND").addClass("info_noticia").attr('type','submit');
                        $(".recortar10").removeClass("recortar");
                        $(".canvas").removeClass("recortar");
                        $(".b1").addClass("paso");
                        $(".titulo_pasos").html("LABEL_STEP_3");
                        if(texto!=""){
                                seis=true;
                                siete=true;
                        }
                        cinco=true;
                        dos=true;
                        cuatro=true;
                        setTimeout(() => {
                                actualizar2();          
                        }, actualizar());
                })

                var cli = false, t1= false, t2=false,t3=false,t4=false,tcli=false;
                var mouse =[];

        
                function raton(elemento, e){
                        return {
                                x:((e.pageX - elemento.offsetLeft - ((ancho/2)-((ancho*scale)/2)))/scale),
                                y:((e.pageY - elemento.offsetTop - ((alto/2)-((alto*scale)/2)))/scale)
                        }
                }

                imagen.src=img;
                $(".recortar10").addClass("recortar");
                $("#boton_recortar").removeClass("boton_normal").addClass("recortar boton_marino").text("LABEL_CUT")
                actualizar();

                $(elemento).mousemove(function(e){
                        mouse = raton(this, e);
                        //console.log("raton x: "+mouse.x+ " raton Y: " +mouse.y+ " tx: "+tx+" ty: "+ty+" txf:"+(txf+tx)+" tyf:"+(tyf+ty) )
                        if(!recorte_listo){
                                if(x<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+yf)>mouse.y){
                                        if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y && (y+yf)>mouse.y){
                                                $(elemento).css("cursor","nw-resize");
                                        }else if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
                                                $(elemento).css("cursor","ne-resize");
                                        }else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
                                                $(elemento).css("cursor","se-resize");
                                        }else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y &&(y+yf)>mouse.y){
                                                $(elemento).css("cursor","sw-resize");
                                        }else{
                                                $(elemento).css("cursor","move");
                                        }
                                }else{
                                        $(elemento).css("cursor","default");
                                }
                        }else if(texto_listo){
                                if(tx-10<mouse.x && tx-10+txf>mouse.x && ty-10<mouse.y && ty-10+tyf>mouse.y){
                                        $(elemento).css("cursor","move");
                                }else if((txf+tx-10)<mouse.x &&(txf+tx-10+20)>mouse.x && (ty-10+tyf)<mouse.y && (ty-10+tyf+20)>mouse.y){
                                        $(elemento).css("cursor","pointer");
                                }else{
                                        $(elemento).css("cursor","default");
                                }
                        }
                        else{
                                $(elemento).css("cursor","default");
                        }
                })
                $(elemento).mousedown(function(e){
                        mouse = raton(this, e);
                        if(!recorte_listo){
                                if(x<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+yf)>mouse.y){
                                        
                     if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y && (y+yf)>mouse.y){
                         t4 = true;
                     }else if((xf+x-cuadro_dimencion)<mouse.x &&(xf+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
                         t3 = true;
                     }else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && y<mouse.y && (y+cuadro_dimencion)>mouse.y){
                         t1 = true;
                     }else if(x<mouse.x &&(cuadro_dimencion+x)>mouse.x && (y+yf-cuadro_dimencion)<mouse.y &&(y+yf)>mouse.y){
                         t2 = true;
                     }else{
                         cli = true;
                     }
                  }
                        }else if(texto_listo){
                                if(tx-10<mouse.x && tx-10+txf>mouse.x && ty-10<mouse.y && ty-10+tyf>mouse.y){
                                        tcli=true;
                                }else if((txf+tx-10)<mouse.x &&(txf+tx-10+20)>mouse.x && (ty-10+tyf)<mouse.y && (ty-10+tyf+20)>mouse.y){
                                        rotar=true;
                                }
                        }                       
                        
                 })

                 $('.editorNoticia').mousemove(function(e){
                        mouse = raton(this, e);
                        if(!recorte_listo){
                                if(cli){
                                        if((mouse.y-(yf/2))>=0&&(mouse.y+(yf/2))<=alto){
                                                y = (mouse.y-(yf/2));
                                        }else{
                                                if((mouse.y-(yf/2))<0){
                                                        y=0;
                                                }
                                                if((mouse.y+(yf/2))>alto){
                                                        y=alto-yf;
                                                }
                                        }
                                        if((mouse.x-(xf/2))>=0&&(mouse.x+(xf/2))<=ancho){
                                                x = (mouse.x-(xf/2));
                                        }else{
                                                if((mouse.x-(xf/2))<0){
                                                        x=0;
                                                }
                                                if((mouse.x+(xf/2))>ancho){
                                                        x=(ancho)-xf;
                                                }
                                        }                               
                                }
                 if(blockCelda){
                                if(t4){
                                        cal1=mouse.y-y;
                                        cal2=cal1/recorte;
                                        cal3=x+cal2;
                                        if(cal2>50){
                                                if(cal3<=ancho&&mouse.y<=alto){
                                                        yf=cal1;        
                                                        xf=cal2;
                                                }else if(cal3<=ancho&&mouse.y>alto){
                                                        yf=alto-y;
                                                        xf=yf/recorte
                                                }else if(cal3>=ancho&&mouse.y<=alto){
                                                        xf=ancho-x;
                                                        yf=xf*recorte;  
                                                }
                                        }
                                }
                                if(t3){
                                        cal1=yf+(y-mouse.y);
                                        cal2=cal1/recorte;
                                        cal3=x+cal2;
                                        if(cal2>50){
                                                if(cal3<=ancho&&mouse.y>=0){
                                                        yf=cal1;        
                                                        xf=cal2;
                                                        y=mouse.y;      
                                                }else if(cal3<=ancho&&mouse.y<0){
                                                        yf=yf+y;
                                                        xf=yf/recorte
                                                        y=0;
                                                }else if(cal3>=ancho&&mouse.y>=0){
                                                        xf=ancho-x;
                                                        y=y+(yf-xf*recorte);
                                                        yf=xf*recorte;  
                                                }
                                                
                                        }
                                                
                                }
                                if(t2){

                    cal1=mouse.y-y;
                    cal2=cal1/recorte;
                    cal3=x+(yf-cal1)/recorte;cal2;
                    if(cal2>50){
                        if(cal3>=0&&mouse.y<=alto){
                            x=cal3;
                            yf=cal1;    
                            xf=cal2;
                        }else if(cal3>0&&mouse.y>alto){
                            yf=alto-y;
                            x=x+(xf-yf/recorte);
                            xf=yf/recorte
                        }else if(cal3<0&&mouse.y<=alto){
                            xf=xf+x;
                            yf=xf*recorte;
                            x=0;        
                        }
                    }   
                    
                }
                if(t1){
                    cal0=y-mouse.y;
                    cal1=yf+cal0;
                    cal2=cal1/recorte;
                    cal3=x-cal0/recorte;
                    if(cal2>50){
                        if(cal3>=0&&mouse.y>=0){
                            yf=cal1;
                            xf=cal2;
                            x=cal3;
                            y=mouse.y;
                        }else if(cal3>0&&mouse.y<0){
                            yf=yf+y;
                            x=x+(xf-yf/recorte);
                            xf=yf/recorte
                            y=0;
                        }else if(cal3<0&&mouse.y>=0){
                            xf=xf+x;
                            y=y+(yf-xf*recorte);
                            yf=xf*recorte;
                            x=0;        
                        }
                    }   

                }
                                }else{
                                if(t4){
                                        
                                        cal1=mouse.y-y;
                                        cal2=mouse.x-x;
                                        if(cal1>50){
                                                yf=mouse.y<=alto?cal1:alto-y;                           
                                        }
                                        if(cal2>50){
                                                xf=mouse.x<=ancho?cal2:ancho-x;
                                        }
                                }
                                
                                if(t3){
                                        cal1=yf-(mouse.y-y);
                                        cal2=mouse.x-x;
                                        if(cal1>50){
                                                
                                                if(mouse.y>=0){
                                                        yf=cal1;
                                                        y=mouse.y;      
                                                }else{
                                                        yf=yf+y;
                                                        y=0;
                                                }
                                        }
                                        if(cal2>50){
                                                xf=mouse.x<=ancho?cal2:ancho-x;
                                        }
                                }
                                /* Izquierda abajo */
                                if(t2){
                                        cal1=mouse.y-y;
                                        cal2=xf-(mouse.x-x);
                                        if(cal1>50){
                                                yf=yf=mouse.y<=alto?cal1:alto-y;
                                        }
                                        if(cal2>50){
                                                if(mouse.x>=0){ 
                                                        xf=cal2;
                                                        x=mouse.x;
                                                }else{
                                                        xf=xf+x;
                                                        x=0;
                                                }
                                        }
                                }
                                /* izquierda arriba */
                                if(t1){

                                        cal1=yf-(mouse.y-y);
                                        cal2=xf-(mouse.x-x);
                                        if(cal1>50){
                                                
                                                if(mouse.y>=0){
                                                        yf=cal1;
                                                        y=mouse.y;      
                                                }else{
                                                        yf=yf+y;
                                                        y=0;
                                                }
                                        }
                                        if(cal2>50){
                                                if(mouse.x>=0){ 
                                                        xf=cal2;
                                                        x=mouse.x;
                                                }else{
                                                        xf=xf+x;
                                                        x=0;
                                                }
                                        }
                                        
                                }
                                }
                                
                        actualizar();
                        }else if(texto_listo){
                                if(tcli){
                                        tx=mouse.x-(txf/2)
                                        ty=mouse.y-(tyf/2)
                                }else if(rotar){

                                }

                                actualizar2();
                        }
                 })
                 $('body').mouseup(function(e){
                        if(!recorte_listo){
                                cli=false;
                                t1=false;
                                t2=false;
                                t3=false;
                                t4=false;
                        }else if (texto_listo) {
                                tcli=false;
                        }
                 })


        }
        /* Titulo */
        
var titulo_noticia, censor_titulo = true, numero_titulo=0;
        $(document).on("keyup change", "#name", function(e){
        console.log(numero_titulo)
        titulo_noticia = $(this).val();
        titulo_elemento= $(".titulo_topico");
        if(titulo_noticia!=""){
                if(censor_titulo){
                        titulo_elemento.html(titulo_noticia);
                        if(titulo_elemento.height()>38){
                                var titulo_noticia2 = "";
                                for(var i =0; i <titulo_noticia.length;i++){
                                        titulo_noticia2 = titulo_noticia2 + titulo_noticia.split("")[i];
                                        titulo_elemento.html(titulo_noticia2);
                                        if(titulo_elemento.height()>38){
                                                titulo_noticia2 = titulo_noticia2.slice(0,-5) + "...";
                                                titulo_elemento.html(titulo_noticia2);
                                                numero_titulo = titulo_noticia2.length;
                                                censor_titulo=false;
                                                break;
                                        }

                                }
                        }else{
                                numero_titulo=0;
                        }
                }else{
                        if(numero_titulo+1>=titulo_noticia.length){
                                titulo_elemento.html(titulo_noticia);
                                censor_titulo=true;
                        }
                }
        }else{
                titulo_elemento.html("LABEL_TITLE");
                censor_titulo = true;
        }
})

});
JS;
$this->inlineScript()->captureEnd();
?>


<!-- Content Header (Page header) -->
<section class="content-header">
        <div class="container-fluid">
        <div class="row mb-2">
                <div class="col-sm-12">
                <h1>LABEL_SLIDES</h1>
                        </div>
                </div>
        </div><!-- /.container-fluid -->
</section>

<section class="content" id='content1'>
        <div class="container-fluid">
        <div class="row">
                <div class="col-12">
                                <div class="card">        
                                        <div class="card-header">
                                                <?php 
                        $form = $this->form;
                        $form->setAttributes([
                            'name'    => 'form-filter',
                            'id'      => 'form-filter',
                        ]);
    
                        $form->prepare();
                        echo $this->form()->openTag($form);
                        ?>
                        <div class="row">
                            <div class="col-md-6 col-sm-12">
                                <div class="form-group">
                                    <?php
                                        $element = $form->get('topic_uuid');
                                    
                                        $element->setOptions(['label' => 'LABEL_TOPIC']);
                                        
                                        $element->setAttributes(['class' => 'form-control']);
                                        echo $this->formLabel($element);
                                        echo $this->formSelect($element);
                                    ?>
                                </div>  
                            </div>
                            <div class="col-md-6 col-sm-12">
                                <div class="form-group">
                                    <?php
                                        $element = $form->get('capsule_uuid');
                                        $element->setOptions(['label' => 'LABEL_CAPSULE']);
                                        $element->setAttributes(['class' => 'form-control']);
                                        echo $this->formLabel($element);
                                        echo $this->formSelect($element);
                                    ?>
                                </div>                          
                            </div>
                        </div>
                                                <?php echo $this->form()->closeTag($form); ?>
                                        </div>            
                                        <div class="card-body">
                                <table id="gridTable" class="table   table-hover">
                                <thead>
                                                        <tr>
                                        <th>LABEL_NAME</th>
                                        <th>LABEL_DETAILS</th>
                                        <th>LABEL_MEDIA</th>    
                                        <th>LABEL_ACTIONS</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                        </table>
                        </div>
                        <div class="card-footer clearfix">
                                <div style="float:right;">
                                                        <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
                                                        <?php if($allowAdd) : ?>
                                                        <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
                                                        <?php endif; ?>
                                                </div>
                        </div>
                        </div>
                </div>     
        </div>          
        </div>
</section> 

                

<!-- The Modal -->
<div  id="company-microlearning-slide-text-add-box" style='display:none'>
        
                <?php 
            $form = $this->formTextAdd;
            $form->setAttributes([
               'method'    => 'post',
               'name'      => 'form-slide-text-add',
               'id'        => 'form-slide-text-add'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?> 

            <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_ADD_TEXT_SLIDE</h4>

             </div>

            
            <div class="grid-padre">
                                <div class="form-group grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                <div class="form-group grid-1-2">
                        <?php 
                    $element = $form->get('description');
                    $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
                    $element->setAttributes(['id' => 'description_add', 'rows' => '2',  'class' => 'form-control']);
                    echo $this->formLabel($element);
                    echo $this->formTextArea($element);
                    ?>
                                </div>
                                <div class="form-group grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                <?php 
                    $element = $form->get('background');
                                        $element->setAttributes([ 'class' => 'background']);
                    echo $this->formHidden($element); 
                ?>
                                <div class="contenido form-group " id="contenido"></div>

                </div>
                
                <?php echo $this->form()->closeTag($form); ?>   

</div>          
                                        
                


<!-- The Modal -->
<div id="company-microlearning-slide-text-edit-box" style='display:none'>
            <?php 
            $form = $this->formTextEdit;
            $form->setAttributes([
               'method'    => 'post',
               'name'      => 'form-slide-text-edit',
               'id'        => 'form-slide-text-edit'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?>
            <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_EDIT_TEXT_SLIDE</h4>

             </div>

            
            <div class="grid-padre">
                                <div class="form-group grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                <div class="form-group grid-1-2">
                        <?php 
                    $element = $form->get('description');
                    $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
                    $element->setAttributes(['id' => 'description_edit', 'rows' => '2',  'class' => 'form-control']);
                    echo $this->formLabel($element);
                    echo $this->formTextArea($element);
                    ?>
                                </div>
                                <div class="form-group grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                <?php 
                    $element = $form->get('background');
                                        $element->setAttributes([ 'class' => 'background']);
                    echo $this->formHidden($element); 
                ?>
                                <div class="contenido form-group " id="contenido"></div>

                </div>
                
                <?php echo $this->form()->closeTag($form); ?>   
        
</div>          
                                        
                        

<!-- The Modal -->
<div class='imageType'  id="company-microlearning-slide-image-add-box" style='display:none' >
                <?php 
            $form = $this->formImageAdd;
            $form->setAttributes([
               'method'    => 'post',
                'name'      => 'form-slide-image-add',
                'id'        => 'form-slide-image-add'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?> 
            <!-- Modal Header -->
            <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_ADD_IMAGE_SLIDE</h4>

             </div>

            <!-- Modal body --> 
            <div class="grid-padre">
                 <div class="form-group grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                
               
                <?php 
                    $element = $form->get('file');
                                        $element->setAttributes([ 'class' => 'file']);
                    echo $this->formHidden($element); 
                ?>
                                <div class="form-group grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                <div class="contenido form-group " id="contenido"></div>
                </div>
                
            
                <?php echo $this->form()->closeTag($form); ?>   
</div>          
                                        
<div class='imageType' id="company-microlearning-slide-image-edit-box" style='display:none' >
            <?php 
            $form = $this->formImageEdit;
            $form->setAttributes([
               'method'    => 'post',
               'name'      => 'form-slide-image-edit',
               'id'        => 'form-slide-image-edit'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?>
            <!-- Modal Header -->
            <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_EDIT_IMAGE_SLIDE</h4>

             </div>

            <!-- Modal body --> 
            <div class="grid-padre">
                 <div class="form-group grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                
               
                <?php 
                    $element = $form->get('file');
                                        $element->setAttributes([ 'class' => 'file']);
                    echo $this->formHidden($element); 
                ?>
                                <div class="form-group grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                
                <div class="contenido form-group " id="contenido"></div>
                </div>
                
            
                <?php echo $this->form()->closeTag($form); ?>   
</div>  


<!-- The Modal -->
                        
                


<!-- The Modal -->
<div  id="company-microlearning-slide-video-add-box"  style='display:none'>

                <?php 
            $form = $this->formVideoAdd;
            $form->setAttributes([
               'method'    => 'post',
                'name'      => 'form-slide-video-add',
                'id'        => 'form-slide-video-add'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?> 
         
              <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_ADD_VIDEO_SLIDE</h4>

             </div>
            <div class="grid-padre">
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                
                                <?php 
                        $element = $form->get('file');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_VIDEO']);
                        $element->setAttributes(['accept' => 'video/webm,video/mpeg,video/mp4']);
                        echo $this->formLabel($element);
                        ?>
                        <div class="file-loading">
                        <?php echo $this->formFile($element);?>
                        </div>
                
                        </div>
                  <?php 
                    $element = $form->get('background');
                                        $element->setAttributes([ 'class' => 'background']);
                    echo $this->formHidden($element); 
                ?>
                        <div class="contenido form-group " id="contenido"></div>
                </div>
                
            <!-- Modal footer -->
                
                <?php echo $this->form()->closeTag($form); ?>   

</div>          
                                        
                


<!-- The Modal -->
<div  id="company-microlearning-slide-video-edit-box"  style='display:none'>

                <?php 
            $form = $this->formVideoEdit;
            $form->setAttributes([
               'method'    => 'post',
               'name'      => 'form-slide-video-edit',
               'id'        => 'form-slide-video-edit'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?> 

         
              <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_EDIT_VIDEO_SLIDE</h4>

             </div>

            <!-- Modal body --> 
            <div class="grid-padre">
                                <div class="form-group grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group grid-1-2">
                        
                                <?php 
                        $element = $form->get('file');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_VIDEO']);
                        $element->setAttributes(['accept' => 'video/webm,video/mpeg,video/mp4']);
                        echo $this->formLabel($element);
                        ?>
                        <div class="file-loading">
                        <?php echo $this->formFile($element);?>
                        </div>
                        
                        </div>
                        <?php 
                    $element = $form->get('background');
                                        $element->setAttributes([ 'class' => 'background']);
                    echo $this->formHidden($element); 
                ?>
                        <div class="contenido form-group " id="contenido"></div>
                </div>
                
    
                <?php echo $this->form()->closeTag($form); ?>
   
</div>          
                                        
                
                

<!-- The Modal -->
<div id="company-microlearning-slide-document-add-box" style='display:none'>

                <?php 
            $form = $this->formDocumentAdd;
            $form->setAttributes([
               'method'    => 'post',
                'name'      => 'form-slide-document-add',
                'id'        => 'form-slide-document-add'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?> 
           
              <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_ADD_DOCUMENT_SLIDE</h4>

             </div>
            <!-- Modal body --> 
            <div class="grid-padre">
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                        
                                <?php 
                        $element = $form->get('file');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_DOCUMENT']);
                        $element->setAttributes(['accept' => 'application/pdf']);
                        echo $this->formLabel($element);
                        ?>
                        <div class="file-loading">
                        <?php echo $this->formFile($element);?>
                        </div>
                        
                        </div>
                  <?php 
                    $element = $form->get('background');
                                        $element->setAttributes([ 'class' => 'background']);
                    echo $this->formHidden($element); 
                ?>
                        <div class="contenido form-group " id="contenido"></div>
                </div>
                
            <!-- Modal footer -->
                
                <?php echo $this->form()->closeTag($form); ?>   
      
</div>          
                                        
                


<!-- The Modal -->
<div id="company-microlearning-slide-document-edit-box" style='display:none'>

                <?php 
            $form = $this->formDocumentEdit;
            $form->setAttributes([
               'method'    => 'post',
               'name'      => 'form-slide-document-edit',
               'id'        => 'form-slide-document-edit'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?> 
            <!-- Modal Header -->
        
              <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_EDIT_DOCUMENT_SLIDE</h4>

             </div>
            <!-- Modal body --> 
            <div class="grid-padre">
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                        
                                <?php 
                        $element = $form->get('file');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_DOCUMENT']);
                        $element->setAttributes(['accept' => 'application/pdf']);
                        echo $this->formLabel($element);
                        ?>
                        <div class="file-loading">
                        <?php echo $this->formFile($element);?>
                        </div>
                        
                        </div>
                        
                        <?php 
                    $element = $form->get('background');
                                        $element->setAttributes([ 'class' => 'background']);
                    echo $this->formHidden($element); 
                ?>
                        <div class="contenido form-group " id="contenido"></div>
                </div>
                
            <!-- Modal footer -->
                
                <?php echo $this->form()->closeTag($form); ?>   
      
</div>          
                                        
                

<!-- The Modal -->
<div  id="company-microlearning-slide-audio-add-box" style='display:none'>

                <?php 
            $form = $this->formAudioAdd;
            $form->setAttributes([
               'method'    => 'post',
                'name'      => 'form-slide-audio-add',
                'id'        => 'form-slide-audio-add'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?> 
            <!-- Modal Header -->
                
              <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_ADD_AUDIO_SLIDE</h4>

             </div>

            <!-- Modal body --> 
            <div class="grid-padre">
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                        
                                <?php 
                        $element = $form->get('file');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_AUDIO']);
                        $element->setAttributes(['accept' => 'audio/x-wav, audio/mpeg']);
                        echo $this->formLabel($element);
                        ?>
                        <div class="file-loading">
                        <?php echo $this->formFile($element);?>
                        </div>
                        
                        </div>
                        <?php 
                    $element = $form->get('background');
                                        $element->setAttributes([ 'class' => 'background']);
                    echo $this->formHidden($element); 
                ?>
                        <div class="contenido form-group " id="contenido"></div>
                </div>
                
            <!-- Modal footer -->
                
                <?php echo $this->form()->closeTag($form); ?>   
       
</div>          
                                        
                

<!-- The Modal -->
<div  id="company-microlearning-slide-audio-edit-box" style='display:none'>

                <?php 
            $form = $this->formAudioEdit;
            $form->setAttributes([
               'method'    => 'post',
               'name'      => 'form-slide-audio-edit',
               'id'        => 'form-slide-audio-edit'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?> 

            <!-- Modal Header -->
                
              <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_EDIT_AUDIO_SLIDE</h4>

             </div>
            <!-- Modal body --> 
            <div class="grid-padre">
                                <div class="form-group">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                        
                                <?php 
                        $element = $form->get('file');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_AUDIO']);
                        $element->setAttributes(['accept' => 'audio/x-wav, audio/mpeg']);
                        echo $this->formLabel($element);
                        ?>
                        <div class="file-loading">
                        <?php echo $this->formFile($element);?>
                        </div>
               
                        </div>
                        
                        <?php 
                    $element = $form->get('background');
                                        $element->setAttributes([ 'class' => 'background']);
                    echo $this->formHidden($element); 
                ?>
                        <div class="contenido form-group " id="contenido"></div>
                </div>
                
            <!-- Modal footer -->
                
                <?php echo $this->form()->closeTag($form); ?>
       
</div>          
                                        
                

<!-- The Modal -->
<div  id="company-microlearning-slide-quizz-add-box" style='display:none'>

                <?php 
            $form = $this->formQuizzAdd;
            $form->setAttributes([
               'method'    => 'post',
                'name'      => 'form-slide-quizz-add',
                'id'        => 'form-slide-quizz-add'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?> 
            <!-- Modal Header -->
                
              <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_ADD_QUIZ_SLIDE</h4>

             </div>
            <!-- Modal body --> 
            <div class="grid-padre">
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                        
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('quiz_id');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_QUIZ']);
                        echo $this->formLabel($element);
                        echo $this->formSelect($element);
                    ?>
                                </div>
                <?php 
                    $element = $form->get('background');
                                        $element->setAttributes([ 'class' => 'background']);
                    echo $this->formHidden($element); 
                ?>
                        <div class="contenido form-group " id="contenido"></div>
                </div>
                
            <!-- Modal footer -->
                
                <?php echo $this->form()->closeTag($form); ?>   
        
</div>          
                                        
                

<!-- The Modal -->
<div  id="company-microlearning-slide-quizz-edit-box" style='display:none'>

                <?php 
            $form = $this->formQuizzEdit;
            $form->setAttributes([
               'method'    => 'post',
               'name'      => 'form-slide-quizz-edit',
               'id'        => 'form-slide-quizz-edit'
            ]);  
            $form->prepare();
            echo $this->form()->openTag($form);
            
            $element = $form->get('type');
            echo $this->formHidden($element);
            
            ?> 

            <!-- Modal Header -->
                
              <div class="d-flex justify-content-center tituloEditor">
              <h4>LABEL_EDIT_QUIZ_SLIDE</h4>

             </div>
            <!-- Modal body --> 
            <div class="grid-padre">
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('name');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_NAME']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('order');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_ORDER']);
                        echo $this->formLabel($element);
                        echo $this->formText($element);
                    ?>
                                </div>
                        
                                <div class="form-group  grid-1-2">
                                <?php 
                        $element = $form->get('quiz_id');
                        $element->setAttributes(['class' => 'form-control']);
                        $element->setOptions(['label' => 'LABEL_QUIZ']);
                        echo $this->formLabel($element);
                        echo $this->formSelect($element);
                    ?>
                                </div>
                                <?php 
                    $element = $form->get('background');
                                        $element->setAttributes([ 'class' => 'background']);
                    echo $this->formHidden($element); 
                ?>
                        <div class="contenido form-group " id="contenido"></div>
                                
                </div>
                
            <!-- Modal footer -->
                <
                
                <?php echo $this->form()->closeTag($form); ?>   
     
</div>          
                                        
                

<!-- The Modal -->
<div class="modal" id="company-microlearning-play-video-box" >
        <div class="modal-dialog ">
        <div class="modal-content">

            <!-- Modal Header -->
                <div class="modal-header">
                        <h4 class="modal-title">LABEL_PLAY_VIDEO</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>

            <!-- Modal body --> 
            <div class="modal-body">
                                <video src=""  style="width: 300px; height: auto" controls preload="false" autoplay="false"  poster="" id="microlearning-play-video"></video>
                </div>
                
            <!-- Modal footer -->
                <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
                </div>
         </div>         
        </div>
</div>          
                                        
                



<!-- The Modal -->
<div class="modal" id="company-microlearning-play-audio-box" >
        <div class="modal-dialog ">
        <div class="modal-content">

            <!-- Modal Header -->
                <div class="modal-header">
                        <h4 class="modal-title">LABEL_PLAY_AUDIO</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>

            <!-- Modal body --> 
            <div class="modal-body">
                                <audio src="" controls autoplay="false"  id="microlearning-play-audio" >
                  Your browser does not support the <code>audio</code> element.
                </audio>
                </div>
                
            <!-- Modal footer -->
                <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
                </div>
         </div>         
        </div>
</div>          
                                        

<!-- The Modal -->
<div class="modal" id="company-microlearning-view-image-box">
        <div class="modal-dialog ">
        <div class="modal-content">

            <!-- Modal Header -->
                <div class="modal-header">
                        <h4 class="modal-title">LABEL_IMAGE</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>

            <!-- Modal body --> 
            <div class="modal-body text-center">
                                <img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-view" />
                </div>
                
            <!-- Modal footer -->
                <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
                </div>
         </div>         
        </div>
</div>                  


<!-- The Modal -->
<div class="modal" id="company-microlearning-view-document-box">
        <div class="modal-dialog ">
        <div class="modal-content">

            <!-- Modal Header -->
                <div class="modal-header">
                        <h4 class="modal-title">LABEL_DOCUMENT</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>

            <!-- Modal body --> 
            <div class="modal-body text-center">
                <iframe id="document-view" style="width: 450px; height: 300px; scroll: auto">
                
                </iframe>
        </div>
                
            <!-- Modal footer -->
                <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
                </div>
         </div>         
        </div>
</div>          


<!-- The Modal -->
<div class="modal" id="company-microlearning-view-text-box">
        <div class="modal-dialog modal-xl">
        <div class="modal-content">

            <!-- Modal Header -->
                <div class="modal-header">
                        <h4 class="modal-title">LABEL_TEXT</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>

            <!-- Modal body --> 
            <div class="modal-body" >
                <div id="document-text" style="width: 100%; height: 300px; scroll: auto; overflow: auto;">

                
                </div>

        </div>
                
            <!-- Modal footer -->
                <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
                </div>
         </div>         
        </div>
</div>   


<!-- The Modal -->
<div class="modal" id="company-microlearning-add-capsule-type-box">
        <div class="modal-dialog ">
        <div class="modal-content">

            <!-- Modal Header -->
                <div class="modal-header">
                        <h5 class="modal-title">LABEL_ADD_CAPSULE_SELECT_TYPE</h5>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>

            <!-- Modal body --> 
            <div class="modal-body">
                <div class="d-flex w-100 flex-column">
                    <div class="row mb-4 mt-4">
                        <div class="col-4 d-flex justify-content-center"><button type="button" class="btn btn-primary btn-sm  btn-add-image"><i class="fa fa-picture-o mr-2" aria-hidden="true"></i> Imagen </button></div>
                        <div class="col-4 d-flex justify-content-center"><button type="button" class="btn btn-primary btn-sm   btn-add-text"><i class="fa fa-file-text-o mr-2" aria-hidden="true"></i> Texto </button></div>
                        <div class="col-4 d-flex justify-content-center"><button type="button" class="btn btn-primary  btn-sm btn-add-video"><i class="fa fa-video-camera mr-2" aria-hidden="true"></i> Video </button></div>
                        
                        
                    </div>
                    <div class="row mb-4">
                        <div class="col-4 d-flex justify-content-center"><button type="button" class="btn btn-primary btn-sm btn-add-document"><i class="fa fa-file mr-2" aria-hidden="true"></i> Documento </button></div>
                        <div class="col-4 d-flex justify-content-center"><button type="button" class="btn btn-primary  btn-sm btn-add-audio"><i class="fa fa-music mr-2" aria-hidden="true"></i> Audio </button></div>
                        <div class="col-4 d-flex justify-content-center"><button type="button" class="btn btn-primary  btn-sm btn-add-quizz"><i class="fa fa-question mr-2" aria-hidden="true"></i> Cuestionario </button></div>
                        
                        
                    </div>
                    <div class='d-flex justify-content-between'>
                        
                        
                        
                    </div>
                </div>



                                
                </div>
                
            <!-- Modal footer -->
                <div class="modal-footer">
                        <button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">LABEL_CLOSE</button>
                </div>
         </div>         
        </div>
</div>