Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6094 | Ir a la última revisión | | Ultima modificación | Ver Log |

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