Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

<?php 
use LeadersLinked\Model\ContentReaction;

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


$this->inlineScript()->appendFile($this->basePath('vendors/ckeditor/ckeditor.js'));

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

$this->inlineScript()->appendFile($this->basePath('vendors/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
$this->inlineScript()->appendFile($this->basePath('vendors/jsrender/jsrender.min.js'));



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



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



jQuery( document ).ready(function( $ ) {
   
    $.fn.reload = function() {
        NProgress.start(); 

        $('.posts-section').show();
        $.ajax({
            'dataType'  : 'json',
            'accept'    : 'application/json',
            'method'    : 'get',
            'url'       :  '$routeComments'
        }).done(function(response) {
            if(response['success']) {
                $('#comment-list').html(
                    $( "#commentTemplate" ).render( response['data'])
                );
    
            } else {
                $.fn.showError(response['data']);
            } 


        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            $('.posts-section').hide();
           NProgress.done();
        });

    }
    
    
    $.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 validator = $('#form-comment').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'comment': {
                required: true,
                maxlength: 256,
            },
        },
        submitHandler: function(form)
        {

                        NProgress.start();
            $.ajax({
                    'dataType'  : 'json',
                    'accept'    : 'application/json',
                    'method'    : 'post',
                    'url'       : '$routeCommentAdd',
                    'data'      :  $('#form-comment').serialize()

            }).done(function(response) {
                                if(response['success']) {
                    $('#form-comment #comment').val('');
                    $('#comment-list').append(
                        $( "#commentTemplate" ).render( response['data'])
                    );
                } else {
                    validator.resetForm();
                    if(jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else  {
                        $.each(response['data'], function( fieldname, errors ) {
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function( jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
            });
            return false;
        },
        invalidHandler: function(form, validator) {
            
        }
    });


    $('body').on('click', 'a.btn-comment-trash', function(e) {
        e.preventDefault();
        var action = $(this).data('link');
        var unique = $(this).data('comment-unique');


        NProgress.start();
        $.ajax({
            'dataType'  : 'json',
            'accept'    : 'application/json',
            'method'    : 'post',
            'url'       :  action,
        }).done(function(response) {
            if(response['success']) {
               $('div.comment-' + unique).remove();
            } else {
                $.fn.showError(response['data']);
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });

    });

    $('body').on('click', 'button.btn-save-reaction', function(e) {
        e.preventDefault();
        var reaction = $(this).data('reaction');

        NProgress.start();
        $.ajax({
            'dataType'  : 'json',
            'accept'    : 'application/json',
            'method'    : 'post',
            'url'       :  '$routeSaveReaction',
            'data'      : {
                'reaction' : reaction
            }
        }).done(function(response) {
            if(response['success']) {
                 $('#currentReaction').html(
                    $('#reactionTemplate').render({reaction: reaction})
                );
            } else {
                $.fn.showError(response['data']);
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });

    });

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


        NProgress.start();
        $.ajax({
            'dataType'  : 'json',
            'accept'    : 'application/json',
            'method'    : 'post',
            'url'       :  '$routeDeleteReaction',
        }).done(function(response) {
            if(response['success']) {
                 $('#currentReaction').html(
                    $('#reactionTemplate').render({reaction: ''})
                );
            } else {
                $.fn.showError(response['data']);
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });

    });



    $('#paginator-process-comm').click(function(e) {
        e.preventDefault();

        var next_page = $(this).data('next-page');
        $.fn.reload(false, next_page);
        
    });

    $.fn.reload();



    $('#currentReaction').html(
        $('#reactionTemplate').render({reaction: '$reaction'})
    );
});
JS;
$this->inlineScript()->captureEnd();


$this->headStyle()->captureStart();
echo <<<EOT


.knowledge-record-card {
    width: 100%;
    padding: 25px 20px;
    border: 1px solid var(--border-primary);
    background-color: var(--bg-color);
    text-align: center;
    border-radius: 10px;
}

.knowledge-record-card-category {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400;
    font-size: 16px;
    line-height: 19px;
    display: flex;
    align-items: center;
    
    color: #666666;
    margin-top: 3px;
}


.knowledge-record-card-title {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 800;
    font-size: 16px;
    line-height: 19px;
    /* identical to box height */
    
    display: flex;
    align-items: center;
    
    color: #666666;
    margin-top: 3px;
}

.knowledge-record-card-description {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400;
    font-size: 14px;
    line-height: 16px;
    text-align: justify;
    text-justify: inter-word;
    
    color: #666666;
    margin-top: 3px;
}

.knowledge-record-card-image  img {
    width: 100%;
    height: auto;
}

.knowledge-record-card-actions {
    line-height: 20px;
}

.knowledge-record-card-actions-edit {
  float: left;
}

.knowledge-record-card-actions-delete {
  float: right;
}

EOT;    
$this->headStyle()->captureEnd();


?>

<section class="companies-info container">
        <div class="company-title">
                <h1 class="title mx-auto">LABEL_KNOWLEDGE_AREA_TITLE</h1>
        </div>

        <div class="row">
            <div class="col-12 ">
            <div class="knowledge-record-card">
                <div class="knowledge-record-card-image">
                   <img src="<?php echo $image ?>" alt="">
                </div>
                <div class="knowledge-record-card-category">
                    <?php echo $category ?>
                </div>
                <div class="knowledge-record-card-title">
                    <?php echo $title ?>
                </div>
                <div class="knowledge-record-card-description">
                   <?php echo $description ?>
                </div>
                <div class="knowledge-record-card-actions text-right">
                    <?php if($attachment) : ?>
                         <a href="<?php echo $attachment ?>" target="_blank"> LABEL_KNOWLEDGE_AREA_DOWNLOAD_ATTACHMENT </a>
     
                    <?php endif; ?>
                    
                    <?php if($link) : ?>
                         <a href="<?php echo $link ?>" target="_blank"> LABEL_KNOWLEDGE_AREA_GO_TO_LINK </a>
                    <?php endif; ?>
    
                </div>
            </div>
        </div>
        
        </div>  
        <div class="row">
            <div class="col-12 ">
                                 
                        <div class="posts-section" >
                        <div class="process-comm" id="paginator-process-comm"> 
                                <div class="spinner">
                        <div class="bounce1"></div>
                        <div class="bounce2"></div>
                        <div class="bounce3"></div>
                        </div>
                                </div>
                        </div>
                                                        
        
                <div class="comment-section">
            <div class="comment-sec">
                <ul id="comment-list">

                </ul>
                </div>
        </div>
        
        <div >
                Acción 
                <div id="currentReaction"></div>
        </div>
        <?php ?>

        <div class="buttons-reaction ">
                <button class="btn-save-reaction" data-reaction="<?php echo ContentReaction::REACTION_RECOMMENDED ?>" title="Me gusta"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="RecommendIcon" style="color: rgb(116, 5, 249);"><path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm6 9.8a.9.9 0 0 1-.1.5l-2.1 4.9a1.34 1.34 0 0 1-1.3.8H9a2 2 0 0 1-2-2v-5a1.28 1.28 0 0 1 .4-1L12 5l.69.69a1.08 1.08 0 0 1 .3.7v.2L12.41 10H17a1 1 0 0 1 1 1z"></path></svg></button>
                <button class="btn-save-reaction" data-reaction="<?php echo ContentReaction::REACTION_SUPPORT ?>" title="Dar apoyo"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="VolunteerActivismIcon" style="color: rgb(100, 149, 237);"><path d="M1 11h4v11H1zm15-7.75C16.65 2.49 17.66 2 18.7 2 20.55 2 22 3.45 22 5.3c0 2.27-2.91 4.9-6 7.7-3.09-2.81-6-5.44-6-7.7C10 3.45 11.45 2 13.3 2c1.04 0 2.05.49 2.7 1.25zM20 17h-7l-2.09-.73.33-.94L13 16h2.82c.65 0 1.18-.53 1.18-1.18 0-.49-.31-.93-.77-1.11L8.97 11H7v9.02L14 22l8.01-3c-.01-1.1-.9-2-2.01-2z"></path></svg></button>
                <button class="btn-save-reaction" data-reaction="<?php echo ContentReaction::REACTION_LOVE ?>" title="Me encanta"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="FavoriteTwoToneIcon" style="color: rgb(223, 112, 77);"><path d="M16.5 5c-1.54 0-3.04.99-3.56 2.36h-1.87C10.54 5.99 9.04 5 7.5 5 5.5 5 4 6.5 4 8.5c0 2.89 3.14 5.74 7.9 10.05l.1.1.1-.1C16.86 14.24 20 11.39 20 8.5c0-2-1.5-3.5-3.5-3.5z" opacity=".3"></path><path d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"></path></svg></button>
                <button class="btn-save-reaction" data-reaction="<?php echo ContentReaction::REACTION_INTEREST ?>" title="Me interesa"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="TungstenIcon" style="color: rgb(245, 187, 92);"><path d="M11 19h2v3h-2zm-9-8h3v2H2zm17 0h3v2h-3zm-3.106 6.8014 1.4072-1.4071 2.1213 2.1213-1.4071 1.4071zm-11.3099.7071 2.1214-2.1213 1.4071 1.4072-2.1213 2.1213zM15 8.02V3H9v5.02c-1.21.92-2 2.35-2 3.98 0 2.76 2.24 5 5 5s5-2.24 5-5c0-1.63-.79-3.06-2-3.98zM11 5h2v2.1c-.32-.06-.66-.1-1-.1s-.68.04-1 .1V5z"></path></svg></button>
                <button class="btn-save-reaction" data-reaction="<?php echo ContentReaction::REACTION_FUN ?>" title="Me divierte"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="EmojiEmotionsIcon" style="color: rgb(255, 127, 80);"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM8.5 8c.83 0 1.5.67 1.5 1.5S9.33 11 8.5 11 7 10.33 7 9.5 7.67 8 8.5 8zM12 18c-2.28 0-4.22-1.66-5-4h10c-.78 2.34-2.72 4-5 4zm3.5-7c-.83 0-1.5-.67-1.5-1.5S14.67 8 15.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path></svg></button>
                <button class="btn-delete-reaction"><i class="fa fa-trash" aria-hidden="true"></i></button>
        </div>
        </div>
        <div class="comment_box">
            <form name="form-comment" id="form-comment" class="form-comment">
                <input type="text" name="comment" id="comment" maxlength="256"  placeholder="LABEL_WRITE_A_COMMENT">
                <button type="submit">LABEL_SEND</button>
            </form>
        </div>
        
        </div>
        

</section>


<script id="reactionTemplate" type="text/x-jsrender">
{{if reaction === '<?php  echo ContentReaction::REACTION_FUN ?>'}}
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="EmojiEmotionsIcon" style="color: rgb(255, 127, 80);"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM8.5 8c.83 0 1.5.67 1.5 1.5S9.33 11 8.5 11 7 10.33 7 9.5 7.67 8 8.5 8zM12 18c-2.28 0-4.22-1.66-5-4h10c-.78 2.34-2.72 4-5 4zm3.5-7c-.83 0-1.5-.67-1.5-1.5S14.67 8 15.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path></svg>
{{/if}}         
{{if reaction === '<?php  echo ContentReaction::REACTION_INTEREST ?>'}}
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="TungstenIcon" style="color: rgb(245, 187, 92);"><path d="M11 19h2v3h-2zm-9-8h3v2H2zm17 0h3v2h-3zm-3.106 6.8014 1.4072-1.4071 2.1213 2.1213-1.4071 1.4071zm-11.3099.7071 2.1214-2.1213 1.4071 1.4072-2.1213 2.1213zM15 8.02V3H9v5.02c-1.21.92-2 2.35-2 3.98 0 2.76 2.24 5 5 5s5-2.24 5-5c0-1.63-.79-3.06-2-3.98zM11 5h2v2.1c-.32-.06-.66-.1-1-.1s-.68.04-1 .1V5z"></path></svg>
{{/if}} 
{{if reaction === '<?php  echo ContentReaction::REACTION_LOVE ?>'}}
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="FavoriteTwoToneIcon" style="color: rgb(223, 112, 77);"><path d="M16.5 5c-1.54 0-3.04.99-3.56 2.36h-1.87C10.54 5.99 9.04 5 7.5 5 5.5 5 4 6.5 4 8.5c0 2.89 3.14 5.74 7.9 10.05l.1.1.1-.1C16.86 14.24 20 11.39 20 8.5c0-2-1.5-3.5-3.5-3.5z" opacity=".3"></path><path d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"></path></svg>
{{/if}} 
{{if reaction === '<?php  echo ContentReaction::REACTION_RECOMMENDED ?>'}}
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="RecommendIcon" style="color: rgb(116, 5, 249);"><path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm6 9.8a.9.9 0 0 1-.1.5l-2.1 4.9a1.34 1.34 0 0 1-1.3.8H9a2 2 0 0 1-2-2v-5a1.28 1.28 0 0 1 .4-1L12 5l.69.69a1.08 1.08 0 0 1 .3.7v.2L12.41 10H17a1 1 0 0 1 1 1z"></path></svg>
{{/if}} 
{{if reaction === '<?php  echo ContentReaction::REACTION_SUPPORT ?>'}}
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="VolunteerActivismIcon" style="color: rgb(100, 149, 237);"><path d="M1 11h4v11H1zm15-7.75C16.65 2.49 17.66 2 18.7 2 20.55 2 22 3.45 22 5.3c0 2.27-2.91 4.9-6 7.7-3.09-2.81-6-5.44-6-7.7C10 3.45 11.45 2 13.3 2c1.04 0 2.05.49 2.7 1.25zM20 17h-7l-2.09-.73.33-.94L13 16h2.82c.65 0 1.18-.53 1.18-1.18 0-.49-.31-.93-.77-1.11L8.97 11H7v9.02L14 22l8.01-3c-.01-1.1-.9-2-2.01-2z"></path></svg>
{{/if}} 
</script>


<script id="commentTemplate" type="text/x-jsrender">
    <li>
        <div class="comment-list">
               <div class="comment comment-{{:unique}}" >
                  <a href="{{>user_url}}"><h3>{{>user_name}}</h3>
                  <span><img src="<?php echo $this->basePath('images/clock.png') ?>" alt="">{{>time_elapsed}} 
                    {{if link_delete}}
                        <a href="#" class="btn-comment-trash" data-link="{{:link_delete}}" data-comment-unique="{{>unique}}"><i class="fa fa-trash"></i></a> 
                    {{/if}}
                    </span>
                                
                      <p>{{>comment}}</p>
                  </div>
           </div>
    </li>
</script>