Proyectos de Subversion Moodle

Rev

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

Rev 998 Rev 999
Línea 54... Línea 54...
54
        }
54
        }
55
      }
55
      }
56
    },
56
    },
57
    checkInputText: function () {
57
    checkInputText: function () {
58
      var ta = $("#id_mynotecontent-" + CONFIG.instanceid);
58
      var ta = $("#id_mynotecontent-" + CONFIG.instanceid);
-
 
59
 
59
      if (ta.val().length <= CONFIG.maxallowedcharacters) {
60
      if (ta.val().length > CONFIG.maxallowedcharacters) {
60
        $("#addmynote_submit").removeAttr("disabled", "");
-
 
61
        return true;
-
 
62
      } else {
-
 
63
        $("#addmynote_submit").attr("disabled", "disabled");
61
        $("#addmynote_submit").attr("disabled", "true");
64
        return false;
62
        return false;
65
      }
63
      }
-
 
64
 
-
 
65
      $("#addmynote_submit").removeAttr("disabled");
66
      return true;
66
      return true;
67
    },
67
    },
68
    toggle_textarea: function (e) {
68
    toggle_textarea: function (e) {
69
      var ta = $("#id_mynotecontent-" + CONFIG.instanceid);
69
      var ta = $("#id_mynotecontent-" + CONFIG.instanceid);
Línea 184... Línea 184...
184
      ) {
184
      ) {
185
        return false;
185
        return false;
186
      }
186
      }
187
      let editingNoteId = ta.attr("data-editnoteid")
187
      let editingNoteId = ta.attr("data-editnoteid")
188
        ? ta
188
        ? ta
189
            .attr("data-editnoteid")
189
          .attr("data-editnoteid")
190
            .replace("mynote-" + CONFIG.instanceid + "-", "")
190
          .replace("mynote-" + CONFIG.instanceid + "-", "")
191
        : false;
191
        : false;
Línea 192... Línea 192...
192
 
192
 
193
      var arg = {
193
      var arg = {
194
        contextid: CONFIG.contextid,
194
        contextid: CONFIG.contextid,
Línea 236... Línea 236...
236
            $(SELECTORS.cesa_notes_BASE + " .tab-content")
236
            $(SELECTORS.cesa_notes_BASE + " .tab-content")
237
              .not(scope.currenttab)
237
              .not(scope.currenttab)
238
              .css("display", "none");
238
              .css("display", "none");
239
            $(
239
            $(
240
              SELECTORS.cesa_notes_BASE +
240
              SELECTORS.cesa_notes_BASE +
241
                " " +
241
              " " +
242
                scope.currenttab +
242
              scope.currenttab +
243
                ".tab-content"
243
              ".tab-content"
244
            ).css("display", "block");
244
            ).css("display", "block");
245
          }
245
          }
246
          scope.addToList(ret, "add");
246
          scope.addToList(ret, "add");
247
          scope.displaycesa_notes();
247
          scope.displaycesa_notes();
248
          $(SELECTORS.cesa_notes_BASE)
248
          $(SELECTORS.cesa_notes_BASE)
Línea 345... Línea 345...
345
      if (cesa_notescount > 0) {
345
      if (cesa_notescount > 0) {
346
        noteinfo
346
        noteinfo
347
          .find(".count")
347
          .find(".count")
348
          .html(
348
          .html(
349
            M.util.get_string("cesa_notescount", "block_cesa_notes") +
349
            M.util.get_string("cesa_notescount", "block_cesa_notes") +
350
              "" +
350
            "" +
351
              cesa_notescount
351
            cesa_notescount
352
          );
352
          );
353
      } else {
353
      } else {
354
        noteinfo
354
        noteinfo
355
          .find(".count")
355
          .find(".count")
356
          .html(M.util.get_string("nothingtodisplay", "block_cesa_notes"));
356
          .html(M.util.get_string("nothingtodisplay", "block_cesa_notes"));
Línea 569... Línea 569...
569
          scope.toggle_textarea(e);
569
          scope.toggle_textarea(e);
570
        }
570
        }
571
      );
571
      );
572
      $("body").delegate(
572
      $("body").delegate(
573
        "#id_mynotecontent-" + CONFIG.instanceid,
573
        "#id_mynotecontent-" + CONFIG.instanceid,
574
        "change keypress keyup",
574
        "change",
575
        function (e) {
575
        function (e) {
576
          scope.getWarnings(scope.checkInputText());
576
          scope.getWarnings(scope.checkInputText());
577
        }
577
        }
578
      );
578
      );
Línea 642... Línea 642...
642
            });
642
            });
643
          }
643
          }
644
        }
644
        }
645
      );
645
      );
646
    },
646
    },
647
    displayDialogue: function (e) {
647
    /* displayDialogue: function (e) {
648
      var scope = cesa_notes;
648
      var scope = cesa_notes;
649
      if (panel === null) {
649
      if (panel === null) {
650
        str
650
        str
651
          .get_strings([
651
          .get_strings([
652
            { key: "cesa_notes", component: "block_cesa_notes" },
652
            { key: "cesa_notes", component: "block_cesa_notes" },
Línea 774... Línea 774...
774
                        $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).attr('data-loaded', "true");
774
                        $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).attr('data-loaded', "true");
775
                        $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).css('display', 'block');
775
                        $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).css('display', 'block');
776
                    }
776
                    }
Línea 777... Línea 777...
777
 
777
 
778
                    panel.show();*/
778
                    panel.show();*/
779
            /*Y.use('moodle-core-notification-dialogue', function() {
779
    /*Y.use('moodle-core-notification-dialogue', function() {
780
                        
780
                
781
                         // TODO: CESA_NOTES Cambiar esto para que no use yui sino https://docs.moodle.org/dev/AMD_Modal
781
                 // TODO: CESA_NOTES Cambiar esto para que no use yui sino https://docs.moodle.org/dev/AMD_Modal
782
                         
782
                 
783
                        panel = new M.core.dialogue({
783
                panel = new M.core.dialogue({
784
                            draggable: true,
784
                    draggable: true,
785
                            modal: true,
785
                    modal: true,
786
                            closeButton: true,
786
                    closeButton: true,
787
                            headerContent: M.util.get_string('cesa_notes', 'block_cesa_notes'),
787
                    headerContent: M.util.get_string('cesa_notes', 'block_cesa_notes'),
788
                            responsive: true,
788
                    responsive: true,
789
                            classname: 'testing'
789
                    classname: 'testing'
790
                        });
790
                });
791
 
791
 
792
                        panel.set('bodyContent', el.html());
792
                panel.set('bodyContent', el.html());
793
                        if (initnotes === null) {
793
                if (initnotes === null) {
794
                            initnotes = true;                        
794
                    initnotes = true;                        
795
                            // Get initial notes
795
                    // Get initial notes
796
                            scope.getcesa_notes(0);
796
                    scope.getcesa_notes(0);
797
                            $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).attr('data-loaded', "true");
797
                    $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).attr('data-loaded', "true");
798
                            $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).css('display', 'block');
798
                    $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).css('display', 'block');
799
                        }
799
                }
800
                        panel.show();
800
                panel.show();
801
                    });*/
801
            });
802
            //scope.registerActions();
802
    //scope.registerActions();
803
          });
803
  });
804
      } else {
804
} else {
805
        panel.show();
805
panel.show();
806
      }
806
}
807
    },
807
}, */
808
    /**
808
    /**
809
     * Initialize cesa_notes
809
     * Initialize cesa_notes
810
     * @access public
810
     * @access public
811
     * @param {int} instanceid
811
     * @param {int} instanceid
Línea 836... Línea 836...
836
      console.log('Execute init')
836
      console.log('Execute init')
Línea 837... Línea 837...
837
 
837
 
Línea 838... Línea 838...
838
      var scope = cesa_notes;
838
      var scope = cesa_notes;
839
 
839
 
840
      str
840
      str
841
      .get_strings([
841
        .get_strings([
842
        { key: "cesa_notes", component: "block_cesa_notes" },
842
          { key: "cesa_notes", component: "block_cesa_notes" },
843
        { key: "characterlimit", component: "block_cesa_notes" },
843
          { key: "characterlimit", component: "block_cesa_notes" },
844
        { key: "save", component: "block_cesa_notes" },
844
          { key: "save", component: "block_cesa_notes" },
845
        { key: "cancel" },
845
          { key: "cancel" },
846
        {
846
          {
847
          key: "cesa_notessavedundertab",
847
            key: "cesa_notessavedundertab",
848
          component: "block_cesa_notes",
848
            component: "block_cesa_notes",
849
          param: CONFIG.contextareas[scope.currenttabindex],
849
            param: CONFIG.contextareas[scope.currenttabindex],
850
        },
850
          },
851
        { key: "placeholdercontent", component: "block_cesa_notes" },
851
          { key: "placeholdercontent", component: "block_cesa_notes" },
852
      ])
852
        ])
Línea 853... Línea 853...
853
      .done(function (s) {
853
        .done(function (s) {
854
        // Create basic tab structure
854
          // Create basic tab structure
855
 
855
 
856
        let deleteModal = `<div id="cesa_notes_delete_modal">
856
          let deleteModal = `<div id="cesa_notes_delete_modal">
857
                                    <div class="cesa_notes_delete_modal_content">
857
                                    <div class="cesa_notes_delete_modal_content">
858
                                        <p>¿Estás seguro de que quieres eliminar este apunte?</p>
858
                                        <p>¿Estás seguro de que quieres eliminar este apunte?</p>
859
                                        <button id="cesa_notes_modal_cancel_delete">Cancelar</button>
859
                                        <button id="cesa_notes_modal_cancel_delete">Cancelar</button>
Línea 860... Línea 860...
860
                                        <button id="cesa_notes_modal_accept_delete">Eliminar</button>
860
                                        <button id="cesa_notes_modal_accept_delete">Eliminar</button>
861
                                    </div>
861
                                    </div>
862
                                    </div>`;
862
                                    </div>`;
863
 
863
 
864
        var el = $("<div></div>").append(
864
          var el = $("<div></div>").append(
865
          $(
865
            $(
866
            '<div id="' +
866
              '<div id="' +
867
              CSS.cesa_notes_BASE +
867
              CSS.cesa_notes_BASE +
868
              '" class="' +
868
              '" class="' +
869
              CSS.cesa_notes_BASE +
869
              CSS.cesa_notes_BASE +
870
              '">' +
870
              '">' +
871
              deleteModal +
871
              deleteModal +
872
              "</div>"
872
              "</div>"
873
          )
873
            )
874
            .append(
874
              .append(
875
              '<div class="inputarea"><div class="responsetext"></div><div class="cesa-notes-limit" id="addmynote-label-' +
875
                '<div class="inputarea"><div class="responsetext"></div><div class="cesa-notes-limit" id="addmynote-label-' +
876
                CONFIG.instanceid +
876
                CONFIG.instanceid +
877
                '">' +
877
                '">' +
878
                s[1] +
878
                s[1] +
879
                " " +
879
                " " +
880
                CONFIG.maxallowedcharacters +
880
                CONFIG.maxallowedcharacters +
881
                '<span class="warning"></span></div>' +
881
                '<span class="warning"></span></div>' +
882
                '<div class="textarea"><textarea id="id_mynotecontent-' +
882
                '<div class="textarea">' +
883
                CONFIG.instanceid +
883
                '<textarea id="id_mynotecontent-' + CONFIG.instanceid +
884
                '" name="mynotecontent" rows="2">' +
884
                '" name="mynotecontent" rows="2">' +
885
                s[5] +
885
                s[5] +
-
 
886
                "</textarea></div>" +
886
                "</textarea></div>" +
887
                '<p class="notesavedhint">' +
-
 
888
                s[4] +
-
 
889
                "</p>" +
887
                '<p class="notesavedhint">' +
890
                '<div class="cesa_notes_buttons_container">' +
888
                s[4] +
891
                '<button class="j-delete-cesa-note">Eliminar</button>' +
889
                "</p>" +
892
                '<button type="submit" id="addmynote_submit"></button>' +
890
                '<p class="cesa_notes_buttons_container"><button class="j-delete-cesa-note">Eliminar</button><input type="submit" id="addmynote_submit"/> </p>' +
893
                '</div>' +
891
                '<p class="cesa_note_bottom_container"><a class="cesa_notes_print" target="_blank" href="' +
894
                '<p class="cesa_note_bottom_container"><a class="cesa_notes_print" target="_blank" href="' +
892
                CONFIG.printapi +
895
                CONFIG.printapi +
893
                '">Imprimir notas</a> </p>' +
896
                '">Imprimir notas</a> </p>' +
894
                "</div>"
897
                "</div>"
895
            )
898
              )
896
            .append($('<ul class="tabs-menu"></ul>'))
899
              .append($('<ul class="tabs-menu"></ul>'))
-
 
900
              .append($('<div class="tab"></div>'))
897
            .append($('<div class="tab"></div>'))
901
          );
898
        );
902
          el.find("#addmynote_submit").append(s[2]);
899
        el.find("#addmynote_submit").attr("value", s[2]);
903
          el.find("#addmynote_cancel").attr("value", s[3]);
900
        el.find("#addmynote_cancel").attr("value", s[3]);
904
 
901
        var tabsmenu = "";
905
          var tabsmenu = "";
902
        var tabcontents = "";
906
          var tabcontents = "";
903
        var i = "";
907
          var i = "";
-
 
908
          for (i in CONFIG.contextareas) {
-
 
909
            if (scope.currenttabindex == i) {
-
 
910
              tabsmenu +=
-
 
911
                '<li class="current" id="tab-' +
-
 
912
                CONFIG.prefix +
-
 
913
                i +
-
 
914
                '"><div class="menu-item">' +
-
 
915
                CONFIG.contextareas[i] +
-
 
916
                "</div></li>";
-
 
917
            } else {
-
 
918
              tabsmenu +=
-
 
919
                '<li class="" id="tab-' +
-
 
920
                CONFIG.prefix +
-
 
921
                i +
-
 
922
                '"><div class="menu-item">' +
-
 
923
                CONFIG.contextareas[i] +
904
        for (i in CONFIG.contextareas) {
924
                "</div></li>";
905
          if (scope.currenttabindex == i) {
925
            }
906
            tabsmenu +=
926
            tabcontents +=
907
              '<li class="current" id="tab-' +
927
              '<div class="tab-content" id="' +
908
              CONFIG.prefix +
-
 
909
              i +
-
 
910
              '"><div class="menu-item">' +
-
 
911
              CONFIG.contextareas[i] +
928
              CONFIG.prefix +
912
              "</div></li>";
929
              i +
913
          } else {
930
              '" onpage="0" notes-count="0">' +
914
            tabsmenu +=
931
              '<div class="notes-info"><div class="cesa_notes-paging"></div><div class="count"></div></div>' +
915
              '<li class="" id="tab-' +
-
 
916
              CONFIG.prefix +
932
              '<ul id="' +
917
              i +
933
              CONFIG.prefix +
918
              '"><div class="menu-item">' +
-
 
919
              CONFIG.contextareas[i] +
-
 
920
              "</div></li>";
-
 
921
          }
-
 
922
          tabcontents +=
-
 
923
            '<div class="tab-content" id="' +
-
 
924
            CONFIG.prefix +
-
 
925
            i +
-
 
926
            '" onpage="0" notes-count="0">' +
-
 
927
            '<div class="notes-info"><div class="cesa_notes-paging"></div><div class="count"></div></div>' +
-
 
928
            '<ul id="' +
-
 
929
            CONFIG.prefix +
-
 
930
            i +
934
              i +
931
            '-list" class="cesa_notes_lists"></ul>' +
935
              '-list" class="cesa_notes_lists"></ul>' +
932
            "</div>";
936
              "</div>";
933
        }
937
          }
934
        el.find(".tabs-menu").append(tabsmenu);
938
          el.find(".tabs-menu").append(tabsmenu);
935
        el.find(".tab").append($(tabcontents));
939
          el.find(".tab").append($(tabcontents));
936
      
940
 
937
        $(SELECTORS.cesa_notes_ROOT).html(el.html());
941
          $(SELECTORS.cesa_notes_ROOT).html(el.html());
938
 
942
 
939
        /* if (initnotes === null) {
943
          /* if (initnotes === null) {
940
          initnotes = true;
944
            initnotes = true;
941
          // Get initial notes
945
            // Get initial notes
942
          scope.getcesa_notes(0);
946
            scope.getcesa_notes(0);
943
          $(SELECTORS.cesa_notes_BASE)
947
            $(SELECTORS.cesa_notes_BASE)
944
            .find(scope.currenttab)
948
              .find(scope.currenttab)
-
 
949
              .attr("data-loaded", "true");
-
 
950
            $(SELECTORS.cesa_notes_BASE)
-
 
951
              .find(scope.currenttab)
945
            .attr("data-loaded", "true");
952
              .css("display", "block");
Línea 946... Línea -...
946
          $(SELECTORS.cesa_notes_BASE)
-
 
947
            .find(scope.currenttab)
-
 
Línea 948... Línea -...
948
            .css("display", "block");
-
 
949
        }
953
          }
950
 
954
  
Línea 951... Línea 955...
951
        scope.registerActions(); */
955
          scope.registerActions(); */
952
      });
956
        });