Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6523 | Rev 6552 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6523 Rev 6547
Línea 35... Línea 35...
35
$this->inlineScript()->captureStart();
35
$this->inlineScript()->captureStart();
36
echo <<<JS
36
echo <<<JS
Línea 37... Línea 37...
37
 
37
 
Línea -... Línea 38...
-
 
38
jQuery( document ).ready(function( $ ) {
-
 
39
 
-
 
40
    $.fn.confirmationAnswers = function() {
-
 
41
 
-
 
42
        $('button.btn-my-coach-delete-answer').confirmation({
-
 
43
            rootSelector: 'button.btn-my-coach-delete-answer',
-
 
44
            title : 'LABEL_ARE_YOU_SURE',
-
 
45
            singleton : true,
-
 
46
            btnOkLabel: 'LABEL_YES',
-
 
47
            btnCancelLabel: 'LABEL_NO',
-
 
48
            onConfirm: function(value) {
-
 
49
                var action = $(this).data('link');
-
 
50
                var question = $(this).data('question');
-
 
51
                var answer = $(this).data('answer');
-
 
52
    
-
 
53
 
-
 
54
                NProgress.start();
-
 
55
                $.ajax({
-
 
56
                    'dataType'  : 'json',
-
 
57
                    'accept'    : 'application/json',
-
 
58
                    'method'    : 'post',
-
 
59
                    'url'       :  action,
-
 
60
                }).done(function(response) {
-
 
61
                    if(response['success']) {
-
 
62
 
-
 
63
                        $('#row-' + answer).remove();
-
 
64
 
-
 
65
                        $('#answers-' + question).html(response['data']['total_answers']);
-
 
66
                        $('#my-coach-question-answer-count-answers').html(response['data']['total_answers']);
-
 
67
 
-
 
68
                        $('#reactions-' + question).html( response['data']['total_reactions']);
-
 
69
                        $('#my-coach-question-answer-count-reactions').html( response['data']['total_reactions']);
-
 
70
 
-
 
71
                        $('#comments-' + question).html(response['data']['total_comments']);
-
 
72
                        $('#my-coach-question-answer-count-comments').html(response['data']['total_comments']);
-
 
73
 
-
 
74
                    } else {
-
 
75
                        $.fn.showError(response['data']);
-
 
76
                    }
-
 
77
                }).fail(function( jqXHR, textStatus, errorThrown) {
-
 
78
                    $.fn.showError(textStatus);
-
 
79
                }).always(function() {
-
 
80
                    NProgress.done();
-
 
81
                });
-
 
82
                       
-
 
83
                return false;
-
 
84
            },
-
 
85
        });
Línea 38... Línea 86...
38
jQuery( document ).ready(function( $ ) {
86
    }
Línea 39... Línea 87...
39
 
87
 
Línea 49... Línea 97...
49
            'method'    : 'get',
97
            'method'    : 'get',
50
            'url'       : action,
98
            'url'       : action,
51
        }).done(function(response) {
99
        }).done(function(response) {
52
            if(response['success']) {
100
            if(response['success']) {
53
                $('#my-coach-question-answers-list').empty();
101
                $('#my-coach-question-answers-list').empty();
54
 
-
 
55
 
-
 
56
                if(response['data']['items'].length > 0) {
102
                if(response['data']['items'].length > 0) {
57
 
-
 
58
 
-
 
59
 
-
 
60
                    $( "#my-coach-question-answers-list" ).html(
103
                    $( "#my-coach-question-answers-list" ).html(
61
                		$( "#answerTemplate" ).render( response['data']['items'] )
104
                		$( "#answerTemplate" ).render( response['data']['items'] )
62
                	);
105
                	);
63
                }   
106
                }   
-
 
107
                $.fn.confirmationAnswers();
Línea 64... Línea 108...
64
 
108
 
65
 
-
 
66
                $('button.btn-my-coach-delete-answer').confirmation({
-
 
67
                    rootSelector: 'button.btn-my-coach-delete-answer',
-
 
68
                    title : 'LABEL_ARE_YOU_SURE',
-
 
69
                    singleton : true,
-
 
70
                    btnOkLabel: 'LABEL_YES',
-
 
71
                    btnCancelLabel: 'LABEL_NO',
-
 
72
                    onConfirm: function(value) {
-
 
73
                        var action = $(this).data('link');
-
 
74
                        NProgress.start();
-
 
75
                        $.ajax({
-
 
76
                            'dataType'  : 'json',
-
 
77
                            'accept'    : 'application/json',
-
 
78
                            'method'    : 'post',
-
 
79
                            'url'       :  action,
-
 
80
                        }).done(function(response) {
-
 
81
                            if(response['success']) {
-
 
82
                                $.fn.showSuccess(response['data']);
-
 
83
 
-
 
84
                                $.fn.reload();
-
 
85
                            } else {
-
 
86
                                $.fn.showError(response['data']);
-
 
87
                            }
-
 
88
                        }).fail(function( jqXHR, textStatus, errorThrown) {
-
 
89
                            $.fn.showError(textStatus);
-
 
90
                        }).always(function() {
-
 
91
                            NProgress.done();
-
 
92
                        });
-
 
93
                       
-
 
94
                        return false;
-
 
95
                    },
-
 
Línea 96... Línea 109...
96
                });
109
               
97
 
110
 
98
            } else {
111
            } else {
99
                $.fn.showError(response['data']);
112
                $.fn.showError(response['data']);
Línea 285... Línea 298...
285
        invalidHandler: function(form, validator) {
298
        invalidHandler: function(form, validator) {
Línea 286... Línea 299...
286
            
299
            
287
        }
300
        }
Línea 288... Línea 301...
288
    });
301
    });
289
 
302
 
290
    var validatorAnswer = $('#form-answer').validate({
303
    var  validatorAnswer = $('#form-answer').validate({
291
        debug: true,
304
        debug: true,
292
        onclick: false,
305
        onclick: false,
293
        onkeyup: false,
306
        onkeyup: false,
Línea 302... Línea 315...
302
            },
315
            },
Línea 303... Línea 316...
303
          
316
          
304
        },
317
        },
305
        submitHandler: function(form)
318
        submitHandler: function(form)
306
        {
319
        {
Línea 307... Línea 320...
307
 
320
            
308
 
321
 
309
			NProgress.start();
322
			NProgress.start();
310
            $.ajax({
323
            $.ajax({
Línea 314... Línea 327...
314
                'url'       :  $('#form-answer').attr('action'),
327
                'url'       :  $('#form-answer').attr('action'),
315
                'data'      :  $('#form-answer').serialize(),
328
                'data'      :  $('#form-answer').serialize(),
Línea 316... Línea 329...
316
 
329
 
317
            }).done(function(response) {
330
            }).done(function(response) {
-
 
331
				if(response['success']) {
-
 
332
                    var method = $('#form-answer').data('method');  
-
 
333
                    var answer = $('#form-answer').data('answer');  
-
 
334
 
318
				if(response['success']) {
335
 
Línea -... Línea 336...
-
 
336
                    $('#modal-answer').modal('hide');
319
                    $('#modal-answer').modal('hide');
337
    
320
    
338
                    if(method == 'add') {
321
                    var uuid = $('#row-view').data('question-uuid');
339
                        var uuid = $('#row-view').data('question-uuid');
322
                    $('#answers-' + uuid).html(response['data']['answers']);
340
                        $('#answers-' + uuid).html(response['data']['answers']);
323
                    $('#my-coach-question-answer-count-answers').html(response['data']['answers']);
341
                        $('#my-coach-question-answer-count-answers').html(response['data']['answers']);
-
 
342
                        $('#my-coach-question-answers-list').prepend(
-
 
343
                            $('#answerTemplate').render(response['data']['item'])
-
 
344
                        );
-
 
345
                        $.fn.confirmationAnswers()
-
 
346
                    } else {
-
 
347
                        $('#answer-text-' + answer).empty();
324
                    $('#my-coach-question-answers-list').prepend(
348
                        $('#answer-text-' + answer).html(response['data']['description']);
325
                        $('#answerTemplate').render(response['data']['item'])
349
 
326
                    );
350
                    }
327
                } else {
351
                } else {
328
                    validatorAnswer.resetForm();
352
                    validatorAnswer.resetForm();
329
                    if(jQuery.type(response['data']) == 'string') {
353
                    if(jQuery.type(response['data']) == 'string') {
Línea 484... Línea 508...
484
        }).done(function(response) {
508
        }).done(function(response) {
485
            if(response['success']) {
509
            if(response['success']) {
486
                $('#row-view').data('link-answers', response['data']['link_answers']);
510
                $('#row-view').data('link-answers', response['data']['link_answers']);
487
                $('#row-view').data('question-uuid', response['data']['uuid']);
511
                $('#row-view').data('question-uuid', response['data']['uuid']);
Línea 488... Línea -...
488
 
-
 
489
                $('#my-coach-question-answer-btn-answer').data('link', response['data']['link_answers_add']); 
-
 
Línea -... Línea 512...
-
 
512
 
-
 
513
 
-
 
514
                if(!response['data']['link_answers_add']) {
-
 
515
                    $('#my-coach-question-answer-btn-answer').hide();
-
 
516
                } else {
-
 
517
                    $('#my-coach-question-answer-btn-answer').data('link', response['data']['link_answers_add']); 
Línea -... Línea 518...
-
 
518
                    $('#my-coach-question-answer-btn-answer').show();    
-
 
519
                }
-
 
520
 
-
 
521
                if(!response['data']['link_delete']) {
-
 
522
                    $('#my-coach-question-answer-btn-delete').hide();
-
 
523
                } else {
Línea 490... Línea 524...
490
                $('#my-coach-question-answer-btn-delete').data('link', response['data']['link_delete']); 
524
                    $('#my-coach-question-answer-btn-delete').data('link', response['data']['link_delete']); 
491
 
525
                    $('#my-coach-question-answer-btn-delete').show();
492
 
526
                }
493
 
527
 
Línea 536... Línea 570...
536
        $('#row-view').hide();
570
        $('#row-view').hide();
537
        $('#row-list').show();
571
        $('#row-list').show();
Línea 538... Línea 572...
538
                
572
                
Línea -... Línea 573...
-
 
573
    });
-
 
574
 
-
 
575
    /****** RESPUESTAS ******/
-
 
576
 
-
 
577
    $('body').on('click', 'button.btn-my-coach-edit-answer', function(e) {
-
 
578
        e.preventDefault();
-
 
579
        var action = $(this).data('link');
-
 
580
        var answer = $(this).data('answer');
-
 
581
        NProgress.start();
-
 
582
        $.ajax({
-
 
583
            'dataType'  : 'json',
-
 
584
            'accept'    : 'application/json',
-
 
585
            'method'    : 'get',
-
 
586
            'url'       :  action,
-
 
587
        }).done(function(response) {
-
 
588
            if(response['success']) {
-
 
589
 
-
 
590
                $('#modal-answer-title').html('LABEL_MY_COACH_ANSWER_EDIT');
-
 
591
                $('#form-answer').attr('action', action );
-
 
592
                $('#form-answer').data('method','edit');  
-
 
593
                $('#form-answer').data('answer', answer);  
-
 
594
                CKEDITOR.instances.description_answer.setData(response['data']['description']);
-
 
595
                validatorAnswer.resetForm();
-
 
596
             
-
 
597
                $('#modal-answer').modal('show');
-
 
598
            } else {
-
 
599
                $.fn.showError(response['data']);
-
 
600
            }
-
 
601
        }).fail(function( jqXHR, textStatus, errorThrown) {
-
 
602
            $.fn.showError(textStatus);
-
 
603
        }).always(function() {
-
 
604
            NProgress.done();
-
 
605
        });
-
 
606
 
Línea 539... Línea 607...
539
    });
607
    });
540
 
608
 
-
 
609
 
Línea -... Línea 610...
-
 
610
    $('#my-coach-question-answer-btn-answer').click(function(e) {
541
 
611
        e.preventDefault();
-
 
612
        console.log('agregar respuesta link = ' + $(this).data('link') );
-
 
613
 
542
    $('#my-coach-question-answer-btn-answer').click(function(e) {
614
        $('#modal-answer-title').html('LABEL_MY_COACH_ANSWER_ADD');
543
        e.preventDefault();
615
        $('#form-answer').attr('action', $(this).data('link') );
Línea 544... Línea 616...
544
 
616
        $('#form-answer').data('method','add'); 
545
        $('#form-answer').attr('action', $(this).data('link') );
617
        $('#form-answer').data('answer', '');   
Línea 546... Línea 618...
546
        CKEDITOR.instances.description_answer.setData('');
618
        CKEDITOR.instances.description_answer.setData('');
Línea 957... Línea 1029...
957
    <div class="modal-dialog  modal-xl">
1029
    <div class="modal-dialog  modal-xl">
958
        <div class="modal-content">
1030
        <div class="modal-content">
Línea 959... Línea 1031...
959
 
1031
 
960
            <!-- Modal Header -->
1032
            <!-- Modal Header -->
961
            <div class="modal-header">
1033
            <div class="modal-header">
962
                <h4 class="modal-title">LABEL_MY_COACH_ANSWER_ADD</h4>
1034
                <h4 class="modal-title" id="modal-answer-title"></h4>
963
                <button type="button" class="close" data-dismiss="modal">&times;</button>
1035
                <button type="button" class="close" data-dismiss="modal">&times;</button>
Línea 964... Línea 1036...
964
            </div>
1036
            </div>
965
 
1037
 
Línea 997... Línea 1069...
997
        </div>
1069
        </div>
998
    </div>
1070
    </div>
999
</div>
1071
</div>
Línea 1000... Línea 1072...
1000
 
1072
 
1001
<script id="answerTemplate" type="text/x-jsrender">
1073
<script id="answerTemplate" type="text/x-jsrender">
1002
<div class="row">
1074
<div class="row" id="row-{{:uuid}}">
1003
    <div class="col-12 col-md-8 mx-auto">
1075
    <div class="col-12 col-md-8 mx-auto">
1004
        <div class="my-coach-record-card-container" >
1076
        <div class="my-coach-record-card-container" >
1005
            <div class="my-coach-record-card-resume" >
1077
            <div class="my-coach-record-card-resume" >
1006
                <div class="my_coach_question_detail_user_rectangle"> 
1078
                <div class="my_coach_question_detail_user_rectangle"> 
1007
                    <img class="my_coach_question_detail_user_image" src="{{:user_image}}" />
1079
                    <img class="my_coach_question_detail_user_image" src="{{:user_image}}" />
1008
                    <p class="my_coach_question_detail_user_name">{{:user_name}}</p>
1080
                    <p class="my_coach_question_detail_user_name">{{:user_name}}</p>
Línea 1009... Línea 1081...
1009
                </div>
1081
                </div>
1010
 
1082
 
1011
            </div>
1083
            </div>
1012
            <div class="my-coach-record-card-content" >
1084
            <div class="my-coach-record-card-content" >
1013
                <p>{{>description}}</p> 
1085
                <div id="answer-text-{{:uuid}}" >{{:text}}</div> 
1014
                <div class="d-flex align-items-center justify-content-between">
1086
                <div class="d-flex align-items-center justify-content-between">
1015
                   <div>LABEL_DATE  <span>{{:time_elapsed}} </span></div> 
1087
                   <div>LABEL_DATE  <span>{{:time_elapsed}} </span></div> 
1016
                   <div>LABEL_COMMENTS <span id="answer-total-comment-{{:uuid}}">{{:total_comments}}<span></div>
1088
                   <div>LABEL_COMMENTS <span id="answer-total-comment-{{:uuid}}">{{:total_comments}}<span></div>
1017
                   <div>LABEL_REACTIONS <span id="answer-total-reactions-{{:uuid}}">{{:total_reactions}}<span></div>  
1089
                   <div>LABEL_REACTIONS <span id="answer-total-reactions-{{:uuid}}">{{:total_reactions}}<span></div>  
Línea 1018... Línea 1090...
1018
                </div>
1090
                </div>
-
 
1091
            </div>
-
 
1092
 
-
 
1093
 
-
 
1094
            <div class="my-coach-record-card-actions">
-
 
1095
                <div class="d-flex align-items-center justify-content-between">
-
 
1096
                    {{if link_edit }}
-
 
1097
                    <button data-link="{{>link_edit}}" data-answer="{{:uuid}}" class="btn-my-coach-edit-answer"> <i class="fa fa-pencil" aria-hidden="true"></i> LABEL_EDIT </button>
-
 
1098
                    {{/if}}
-
 
1099
                    {{if link_delete }}
-
 
1100
                    <button data-link="{{>link_delete}}" data-question="{{:question_uuid}}" data-answer="{{:uuid}}" class="btn-my-coach-delete-answer"> <i class="fa fa-trash" aria-hidden="true"></i> LABEL_DELETE </button>
1019
            </div>
1101
                    {{/if}}       
1020
 
1102
                </div>
Línea 1021... Línea 1103...
1021
 
1103