Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
6094 stevensc 1
<?php
2
 
6056 efrain 3
use LeadersLinked\Model\ContentReaction;
4
 
5
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
6
$currentUser    = $this->currentUserHelper();
7
$roleName       = $currentUser->getUserTypeId();
8
 
9
 
10
$this->inlineScript()->appendFile($this->basePath('vendors/ckeditor/ckeditor.js'));
11
 
12
$this->headLink()->appendStylesheet($this->basePath('vendors/nprogress/nprogress.css'));
13
$this->inlineScript()->appendFile($this->basePath('vendors/nprogress/nprogress.js'));
14
 
15
$this->inlineScript()->appendFile($this->basePath('vendors/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
16
$this->inlineScript()->appendFile($this->basePath('vendors/jsrender/jsrender.min.js'));
17
 
18
 
19
 
20
$this->inlineScript()->appendFile($this->basePath('vendors/jquery-validation/jquery.validate.js'));
21
$this->inlineScript()->appendFile($this->basePath('vendors/jquery-validation/additional-methods.js'));
22
$this->inlineScript()->appendFile($this->basePath('vendors/jquery-validation/localization/messages_es.js'));
23
 
24
 
25
 
26
$this->inlineScript()->captureStart();
27
echo <<<JS
28
 
29
 
30
 
31
jQuery( document ).ready(function( $ ) {
32
 
33
    $.fn.reload = function() {
34
        NProgress.start();
35
 
36
        $('.posts-section').show();
37
        $.ajax({
38
            'dataType'  : 'json',
39
            'accept'    : 'application/json',
40
            'method'    : 'get',
41
            'url'       :  '$routeComments'
42
        }).done(function(response) {
43
            if(response['success']) {
44
                $('#comment-list').html(
45
                    $( "#commentTemplate" ).render( response['data'])
46
                );
47
 
48
            } else {
49
                $.fn.showError(response['data']);
50
            }
51
 
52
 
53
        }).fail(function( jqXHR, textStatus, errorThrown) {
54
            $.fn.showError(textStatus);
55
        }).always(function() {
56
            $('.posts-section').hide();
57
           NProgress.done();
58
        });
59
 
60
    }
61
 
62
 
63
    $.fn.showFormErrorValidator = function(fieldname, errors) {
64
        var field = $(fieldname);
65
        if(field) {
66
            $(field).addClass('is-invalid');
67
 
68
 
69
            var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
70
            if(element.parent('.btn-file').length) {
71
                error.insertAfter(element.parent().parent());
72
            } else if(element.parent('.toggle').length) {
73
                error.insertAfter(element.parent().parent());
74
            } else {
75
                error.insertAfter(element.parent());
76
            }
77
        }
78
    };
79
 
80
 
81
    var validator = $('#form-comment').validate({
82
        debug: true,
83
        onclick: false,
84
        onkeyup: false,
85
        ignore: [],
86
        rules: {
87
            'comment': {
88
                required: true,
89
                maxlength: 256,
90
            },
91
        },
92
        submitHandler: function(form)
93
        {
94
 
95
			NProgress.start();
96
            $.ajax({
97
                    'dataType'  : 'json',
98
                    'accept'    : 'application/json',
99
                    'method'    : 'post',
100
                    'url'       : '$routeCommentAdd',
101
                    'data'      :  $('#form-comment').serialize()
102
 
103
            }).done(function(response) {
104
				if(response['success']) {
105
                    $('#form-comment #comment').val('');
106
                    $('#comment-list').append(
107
                        $( "#commentTemplate" ).render( response['data'])
108
                    );
109
                } else {
110
                    validator.resetForm();
111
                    if(jQuery.type(response['data']) == 'string') {
112
                        $.fn.showError(response['data']);
113
                    } else  {
114
                        $.each(response['data'], function( fieldname, errors ) {
115
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
116
                        });
117
                    }
118
                }
119
            }).fail(function( jqXHR, textStatus, errorThrown) {
120
                $.fn.showError(textStatus);
121
            }).always(function() {
122
                NProgress.done();
123
            });
124
            return false;
125
        },
126
        invalidHandler: function(form, validator) {
127
 
128
        }
129
    });
130
 
131
 
132
    $('body').on('click', 'a.btn-comment-trash', function(e) {
133
        e.preventDefault();
134
        var action = $(this).data('link');
135
        var unique = $(this).data('comment-unique');
136
 
137
 
138
        NProgress.start();
139
        $.ajax({
140
            'dataType'  : 'json',
141
            'accept'    : 'application/json',
142
            'method'    : 'post',
143
            'url'       :  action,
144
        }).done(function(response) {
145
            if(response['success']) {
146
               $('div.comment-' + unique).remove();
147
            } else {
148
                $.fn.showError(response['data']);
149
            }
150
        }).fail(function( jqXHR, textStatus, errorThrown) {
151
            $.fn.showError(textStatus);
152
        }).always(function() {
153
            NProgress.done();
154
        });
155
 
156
    });
157
 
158
    $('body').on('click', 'button.btn-save-reaction', function(e) {
159
        e.preventDefault();
160
        var reaction = $(this).data('reaction');
161
 
162
        NProgress.start();
163
        $.ajax({
164
            'dataType'  : 'json',
165
            'accept'    : 'application/json',
166
            'method'    : 'post',
167
            'url'       :  '$routeSaveReaction',
168
            'data'      : {
169
                'reaction' : reaction
170
            }
171
        }).done(function(response) {
172
            if(response['success']) {
173
                 $('#currentReaction').html(
174
                    $('#reactionTemplate').render({reaction: reaction})
175
                );
176
            } else {
177
                $.fn.showError(response['data']);
178
            }
179
        }).fail(function( jqXHR, textStatus, errorThrown) {
180
            $.fn.showError(textStatus);
181
        }).always(function() {
182
            NProgress.done();
183
        });
184
 
185
    });
186
 
187
    $('body').on('click', 'button.btn-delete-reaction', function(e) {
188
        e.preventDefault();
189
 
190
 
191
        NProgress.start();
192
        $.ajax({
193
            'dataType'  : 'json',
194
            'accept'    : 'application/json',
195
            'method'    : 'post',
196
            'url'       :  '$routeDeleteReaction',
197
        }).done(function(response) {
198
            if(response['success']) {
199
                 $('#currentReaction').html(
200
                    $('#reactionTemplate').render({reaction: ''})
201
                );
202
            } else {
203
                $.fn.showError(response['data']);
204
            }
205
        }).fail(function( jqXHR, textStatus, errorThrown) {
206
            $.fn.showError(textStatus);
207
        }).always(function() {
208
            NProgress.done();
209
        });
210
 
211
    });
212
 
6138 stevensc 213
    let isMouseHover;
214
 
6126 stevensc 215
    $('body').on('mouseover', '#reaction-container', function(e) {
6138 stevensc 216
        isMouseHover = true;
6120 stevensc 217
        setTimeout(() => {
6125 stevensc 218
            $('.reactions').addClass('active');
6120 stevensc 219
        }, 500);
6116 stevensc 220
    });
6056 efrain 221
 
6126 stevensc 222
    $('body').on('mouseout', '#reaction-container', function(e) {
6136 stevensc 223
        setTimeout(() => {
6138 stevensc 224
            if(isMouseHover) {
6139 stevensc 225
                isMouseHover = false;
6138 stevensc 226
                $('.reactions').removeClass('active');
227
            }
6136 stevensc 228
        }, 800);
6125 stevensc 229
    });
230
 
6056 efrain 231
    $('#paginator-process-comm').click(function(e) {
232
        e.preventDefault();
233
 
234
        var next_page = $(this).data('next-page');
235
        $.fn.reload(false, next_page);
236
 
237
    });
238
 
239
    $.fn.reload();
240
 
241
 
242
 
243
    $('#currentReaction').html(
244
        $('#reactionTemplate').render({reaction: '$reaction'})
245
    );
246
});
247
JS;
6101 stevensc 248
 
6056 efrain 249
$this->inlineScript()->captureEnd();
6101 stevensc 250
$this->headLink()->appendStylesheet('/look-and-field/knowledge.css');
6056 efrain 251
 
252
?>
253
 
6113 stevensc 254
<section class="companies-info container px-0">
6094 stevensc 255
    <div class="company-title">
256
        <h1 class="title mx-auto">LABEL_KNOWLEDGE_AREA_TITLE</h1>
257
    </div>
6056 efrain 258
 
6094 stevensc 259
    <div class="row">
6113 stevensc 260
        <div class="col-12">
261
 
6056 efrain 262
            <div class="knowledge-record-card">
6103 stevensc 263
                <img src="<?php echo $image ?>" alt="">
264
                <h3><?php echo $category ?></h3>
265
                <h2><?php echo $title ?></h2>
266
                <p><?php echo $description ?></p>
6056 efrain 267
                <div class="knowledge-record-card-actions text-right">
6094 stevensc 268
                    <?php if ($attachment) : ?>
269
                        <a href="<?php echo $attachment ?>" target="_blank"> LABEL_KNOWLEDGE_AREA_DOWNLOAD_ATTACHMENT </a>
6056 efrain 270
                    <?php endif; ?>
6094 stevensc 271
 
272
                    <?php if ($link) : ?>
273
                        <a href="<?php echo $link ?>" target="_blank"> LABEL_KNOWLEDGE_AREA_GO_TO_LINK </a>
6056 efrain 274
                    <?php endif; ?>
275
                </div>
6126 stevensc 276
                <div class="position-relative" style="width: fit-content;" id="reaction-container">
6116 stevensc 277
                    <button class="btn reaction-btn" id="currentReaction"></button>
6119 stevensc 278
                    <div class="reactions">
6116 stevensc 279
                        <button class="btn-save-reaction" data-reaction="<?php echo ContentReaction::REACTION_RECOMMENDED ?>" title="Me gusta">
280
                            <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);">
281
                                <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>
282
                            </svg>
283
                        </button>
284
                        <button class="btn-save-reaction" data-reaction="<?php echo ContentReaction::REACTION_SUPPORT ?>" title="Dar apoyo">
285
                            <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);">
286
                                <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>
287
                            </svg>
288
                        </button>
289
                        <button class="btn-save-reaction" data-reaction="<?php echo ContentReaction::REACTION_LOVE ?>" title="Me encanta">
290
                            <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);">
291
                                <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>
292
                                <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>
293
                            </svg>
294
                        </button>
295
                        <button class="btn-save-reaction" data-reaction="<?php echo ContentReaction::REACTION_INTEREST ?>" title="Me interesa">
296
                            <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);">
297
                                <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>
298
                            </svg>
299
                        </button>
300
                        <button class="btn-save-reaction" data-reaction="<?php echo ContentReaction::REACTION_FUN ?>" title="Me divierte">
301
                            <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);">
302
                                <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>
303
                            </svg>
304
                        </button>
305
                        <button class="btn-delete-reaction"><i class="fa fa-trash" aria-hidden="true"></i></button>
6103 stevensc 306
                    </div>
6116 stevensc 307
                </div>
6056 efrain 308
            </div>
6113 stevensc 309
 
6094 stevensc 310
        </div>
6113 stevensc 311
    </div>
6056 efrain 312
 
6094 stevensc 313
    <div class="row">
314
        <div class="col-12 ">
315
            <div class="posts-section">
316
                <div class="process-comm" id="paginator-process-comm">
317
                    <div class="spinner">
318
                        <div class="bounce1"></div>
319
                        <div class="bounce2"></div>
320
                        <div class="bounce3"></div>
321
                    </div>
322
                </div>
323
            </div>
324
            <div class="comment-section">
325
                <div class="comment-sec">
326
                    <ul id="comment-list">
327
                    </ul>
328
                </div>
329
            </div>
330
            <div>
6103 stevensc 331
 
6094 stevensc 332
            </div>
333
            <?php ?>
6056 efrain 334
        </div>
335
        <div class="comment_box">
336
            <form name="form-comment" id="form-comment" class="form-comment">
6094 stevensc 337
                <input type="text" name="comment" id="comment" maxlength="256" placeholder="LABEL_WRITE_A_COMMENT">
6056 efrain 338
                <button type="submit">LABEL_SEND</button>
339
            </form>
340
        </div>
341
 
6094 stevensc 342
    </div>
343
 
344
 
6056 efrain 345
</section>
346
 
347
 
348
<script id="reactionTemplate" type="text/x-jsrender">
6094 stevensc 349
    {{if reaction === '<?php echo ContentReaction::REACTION_FUN ?>'}}
350
    <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);">
351
        <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>
352
    </svg>
353
    {{/if}}
354
    {{if reaction === '<?php echo ContentReaction::REACTION_INTEREST ?>'}}
355
    <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);">
356
        <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>
357
    </svg>
358
    {{/if}}
359
    {{if reaction === '<?php echo ContentReaction::REACTION_LOVE ?>'}}
360
    <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);">
361
        <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>
362
        <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>
363
    </svg>
364
    {{/if}}
365
    {{if reaction === '<?php echo ContentReaction::REACTION_RECOMMENDED ?>'}}
366
    <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);">
367
        <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>
368
    </svg>
369
    {{/if}}
370
    {{if reaction === '<?php echo ContentReaction::REACTION_SUPPORT ?>'}}
371
    <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);">
372
        <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>
373
    </svg>
374
    {{/if}}
6056 efrain 375
</script>
376
 
377
 
378
<script id="commentTemplate" type="text/x-jsrender">
379
    <li>
380
        <div class="comment-list">
381
	       <div class="comment comment-{{:unique}}" >
382
    		  <a href="{{>user_url}}"><h3>{{>user_name}}</h3>
383
    		  <span><img src="<?php echo $this->basePath('images/clock.png') ?>" alt="">{{>time_elapsed}}
384
                    {{if link_delete}}
385
                        <a href="#" class="btn-comment-trash" data-link="{{:link_delete}}" data-comment-unique="{{>unique}}"><i class="fa fa-trash"></i></a>
386
                    {{/if}}
387
                    </span>
388
 
389
		      <p>{{>comment}}</p>
390
		  </div>
391
	   </div>
392
    </li>
6094 stevensc 393
</script>