Proyectos de Subversion Moodle

Rev

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

Rev 981 Rev 982
Línea 641... Línea 641...
641
            });
641
            });
642
          }
642
          }
643
        }
643
        }
644
      );
644
      );
645
    },
645
    },
-
 
646
    displayDialogue: function (e) {
-
 
647
      var scope = cesa_notes;
-
 
648
      if (panel === null) {
-
 
649
        str
-
 
650
          .get_strings([
-
 
651
            { key: "cesa_notes", component: "block_cesa_notes" },
-
 
652
            { key: "characterlimit", component: "block_cesa_notes" },
-
 
653
            { key: "save", component: "block_cesa_notes" },
-
 
654
            { key: "cancel" },
-
 
655
            {
-
 
656
              key: "cesa_notessavedundertab",
-
 
657
              component: "block_cesa_notes",
-
 
658
              param: CONFIG.contextareas[scope.currenttabindex],
-
 
659
            },
-
 
660
            { key: "placeholdercontent", component: "block_cesa_notes" },
-
 
661
          ])
-
 
662
          .done(function (s) {
-
 
663
            // Create basic tab structure
-
 
664
 
-
 
665
            let deleteModal = `<div id="cesa_notes_delete_modal">
-
 
666
                                        <div class="cesa_notes_delete_modal_content">
-
 
667
                                            <p>¿Estás seguro de que quieres eliminar este apunte?</p>
-
 
668
                                            <button id="cesa_notes_modal_cancel_delete">Cancelar</button>
-
 
669
                                            <button id="cesa_notes_modal_accept_delete">Eliminar</button>
-
 
670
                                        </div>
-
 
671
                                        </div>`;
-
 
672
            var el = $("<div></div>").append(
-
 
673
              $(
-
 
674
                '<div id="' +
-
 
675
                  CSS.cesa_notes_BASE +
-
 
676
                  '" class="' +
-
 
677
                  CSS.cesa_notes_BASE +
-
 
678
                  '">' +
-
 
679
                  deleteModal +
-
 
680
                  "</div>"
-
 
681
              )
-
 
682
                .append(
-
 
683
                  '<div class="inputarea"><div class="responsetext"></div><div class="cesa-notes-limit" id="addmynote-label-' +
-
 
684
                    CONFIG.instanceid +
-
 
685
                    '">' +
-
 
686
                    s[1] +
-
 
687
                    " " +
-
 
688
                    CONFIG.maxallowedcharacters +
-
 
689
                    '<span class="warning"></span></div>' +
-
 
690
                    '<div class="textarea"><textarea id="id_mynotecontent-' +
-
 
691
                    CONFIG.instanceid +
-
 
692
                    '" name="mynotecontent" rows="2">' +
-
 
693
                    s[5] +
-
 
694
                    "</textarea></div>" +
-
 
695
                    '<p class="notesavedhint">' +
-
 
696
                    s[4] +
-
 
697
                    "</p>" +
-
 
698
                    '<p class="cesa_notes_buttons_container"><button class="j-delete-cesa-note">Eliminar</button><input type="submit" id="addmynote_submit"/> </p>' +
-
 
699
                    '<p class="cesa_note_bottom_container"><a class="cesa_notes_print" target="_blank" href="' +
-
 
700
                    CONFIG.printapi +
-
 
701
                    '">Imprimir notas</a> </p>' +
-
 
702
                    "</div>"
-
 
703
                )
-
 
704
                .append($('<ul class="tabs-menu"></ul>'))
-
 
705
                .append($('<div class="tab"></div>'))
-
 
706
            );
-
 
707
            el.find("#addmynote_submit").attr("value", s[2]);
-
 
708
            el.find("#addmynote_cancel").attr("value", s[3]);
-
 
709
            var tabsmenu = "";
-
 
710
            var tabcontents = "";
-
 
711
            var i = "";
-
 
712
            for (i in CONFIG.contextareas) {
-
 
713
              if (scope.currenttabindex == i) {
-
 
714
                tabsmenu +=
-
 
715
                  '<li class="current" id="tab-' +
-
 
716
                  CONFIG.prefix +
-
 
717
                  i +
-
 
718
                  '"><div class="menu-item">' +
-
 
719
                  CONFIG.contextareas[i] +
-
 
720
                  "</div></li>";
-
 
721
              } else {
-
 
722
                tabsmenu +=
-
 
723
                  '<li class="" id="tab-' +
-
 
724
                  CONFIG.prefix +
-
 
725
                  i +
-
 
726
                  '"><div class="menu-item">' +
-
 
727
                  CONFIG.contextareas[i] +
-
 
728
                  "</div></li>";
-
 
729
              }
-
 
730
              tabcontents +=
-
 
731
                '<div class="tab-content" id="' +
-
 
732
                CONFIG.prefix +
-
 
733
                i +
-
 
734
                '" onpage="0" notes-count="0">' +
-
 
735
                '<div class="notes-info"><div class="cesa_notes-paging"></div><div class="count"></div></div>' +
-
 
736
                '<ul id="' +
-
 
737
                CONFIG.prefix +
-
 
738
                i +
-
 
739
                '-list" class="cesa_notes_lists"></ul>' +
-
 
740
                "</div>";
-
 
741
            }
-
 
742
            el.find(".tabs-menu").append(tabsmenu);
-
 
743
            el.find(".tab").append($(tabcontents));
-
 
744
            ModalFactory.create({
-
 
745
              title: s[0],
-
 
746
              body: el.html(),
-
 
747
            }).then(function (modal) {
-
 
748
              if (initnotes === null) {
-
 
749
                initnotes = true;
-
 
750
                // Get initial notes
-
 
751
                scope.getcesa_notes(0);
-
 
752
                $(SELECTORS.cesa_notes_BASE)
-
 
753
                  .find(scope.currenttab)
-
 
754
                  .attr("data-loaded", "true");
-
 
755
                $(SELECTORS.cesa_notes_BASE)
-
 
756
                  .find(scope.currenttab)
-
 
757
                  .css("display", "block");
-
 
758
              }
-
 
759
 
-
 
760
              let root = modal.getRoot();
-
 
761
 
-
 
762
              root.addClass("modal_cesa_notes_root");
-
 
763
 
-
 
764
              panel = modal;
-
 
765
              panel.show();
-
 
766
              scope.registerActions();
-
 
767
            });
-
 
768
 
-
 
769
            /*if (initnotes === null) {
-
 
770
                        initnotes = true;                        
-
 
771
                        // Get initial notes
-
 
772
                        scope.getcesa_notes(0);
-
 
773
                        $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).attr('data-loaded', "true");
-
 
774
                        $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).css('display', 'block');
-
 
775
                    }
-
 
776
 
-
 
777
                    panel.show();*/
-
 
778
            /*Y.use('moodle-core-notification-dialogue', function() {
-
 
779
                        
-
 
780
                         // TODO: CESA_NOTES Cambiar esto para que no use yui sino https://docs.moodle.org/dev/AMD_Modal
-
 
781
                         
-
 
782
                        panel = new M.core.dialogue({
-
 
783
                            draggable: true,
-
 
784
                            modal: true,
-
 
785
                            closeButton: true,
-
 
786
                            headerContent: M.util.get_string('cesa_notes', 'block_cesa_notes'),
-
 
787
                            responsive: true,
-
 
788
                            classname: 'testing'
-
 
789
                        });
-
 
790
 
-
 
791
                        panel.set('bodyContent', el.html());
-
 
792
                        if (initnotes === null) {
-
 
793
                            initnotes = true;                        
-
 
794
                            // Get initial notes
-
 
795
                            scope.getcesa_notes(0);
-
 
796
                            $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).attr('data-loaded', "true");
-
 
797
                            $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).css('display', 'block');
-
 
798
                        }
-
 
799
                        panel.show();
-
 
800
                    });*/
-
 
801
            //scope.registerActions();
-
 
802
          });
-
 
803
      } else {
-
 
804
        panel.show();
-
 
805
      }
-
 
806
    },
646
    /**
807
    /**
647
     * Initialize cesa_notes
808
     * Initialize cesa_notes
648
     * @access public
809
     * @access public
649
     * @param {int} instanceid
810
     * @param {int} instanceid
650
     * @param {int} contextid
811
     * @param {int} contextid
Línea 667... Línea 828...
667
      this.defaulttab = "#cesa_notes_" + args.currenttabindex;
828
      this.defaulttab = "#cesa_notes_" + args.currenttabindex;
668
      this.currenttabindex = args.currenttabindex;
829
      this.currenttabindex = args.currenttabindex;
669
      this.api = this.getcesa_notesValidatedUrl(
830
      this.api = this.getcesa_notesValidatedUrl(
670
        M.cfg.wwwroot + "/blocks/cesa_notes/cesa_notes_ajax.php"
831
        M.cfg.wwwroot + "/blocks/cesa_notes/cesa_notes_ajax.php"
671
      );
832
      );
672
      
-
 
673
      var strtitle = M.util.get_string("showcesa_notes", "block_cesa_notes");
833
      var strtitle = M.util.get_string("showcesa_notes", "block_cesa_notes");
674
 
-
 
675
      var scope = cesa_notes;
-
 
676
    
-
 
677
      // Obtiene las cadenas de texto requeridas
-
 
678
      str
-
 
679
        .get_strings([
-
 
680
          { key: "cesa_notes", component: "block_cesa_notes" },
-
 
681
          { key: "characterlimit", component: "block_cesa_notes" },
-
 
682
          { key: "save", component: "block_cesa_notes" },
-
 
683
          { key: "cancel" },
-
 
684
          {
-
 
685
            key: "cesa_notessavedundertab",
-
 
686
            component: "block_cesa_notes",
-
 
687
            param: CONFIG.contextareas[scope.currenttabindex],
-
 
688
          },
-
 
689
          { key: "placeholdercontent", component: "block_cesa_notes" },
-
 
690
        ])
-
 
691
        .done(function (s) {
-
 
692
          // Estructura del modal de eliminación
-
 
693
          const deleteModal = `
-
 
694
            <div id="cesa_notes_delete_modal">
-
 
695
              <div class="cesa_notes_delete_modal_content">
834
      $(".inline-" + CSS.cesa_notes_OPENER).html("hola");
696
                <p>¿Estás seguro de que quieres eliminar este apunte?</p>
-
 
697
                <button id="cesa_notes_modal_cancel_delete">Cancelar</button>
-
 
698
                <button id="cesa_notes_modal_accept_delete">Eliminar</button>
-
 
699
              </div>
-
 
700
            </div>`;
-
 
701
    
-
 
702
          // Contenedor principal
-
 
703
          const el = $("<div></div>").append(
-
 
704
            $(`<div id="${CSS.cesa_notes_BASE}" class="${CSS.cesa_notes_BASE}">${deleteModal}</div>`)
-
 
705
              .append(`
-
 
706
                <div class="inputarea">
-
 
707
                  <div class="responsetext"></div>
-
 
708
                  <div class="cesa-notes-limit" id="addmynote-label-${CONFIG.instanceid}">
-
 
709
                    ${s[1]} ${CONFIG.maxallowedcharacters}
-
 
710
                    <span class="warning"></span>
-
 
711
                  </div>
-
 
712
                  <div class="textarea">
-
 
713
                    <textarea id="id_mynotecontent-${CONFIG.instanceid}" name="mynotecontent" rows="2">
-
 
714
                      ${s[5]}
-
 
715
                    </textarea>
-
 
716
                  </div>
-
 
717
                  <p class="notesavedhint">${s[4]}</p>
-
 
718
                  <p class="cesa_notes_buttons_container">
-
 
719
                    <button class="j-delete-cesa-note">Eliminar</button>
-
 
720
                    <input type="submit" id="addmynote_submit" value="${s[2]}"/>
-
 
721
                  </p>
-
 
722
                  <p class="cesa_note_bottom_container">
-
 
723
                    <a class="cesa_notes_print" target="_blank" href="${CONFIG.printapi}">Imprimir notas</a>
-
 
724
                  </p>
-
 
725
                </div>`)
-
 
726
              .append('<ul class="tabs-menu"></ul>')
-
 
727
              .append('<div class="tab"></div>')
-
 
728
          );
-
 
729
    
-
 
730
          // Creación de las pestañas
-
 
731
          let tabsmenu = "";
-
 
732
          let tabcontents = "";
-
 
733
          CONFIG.contextareas.forEach((area, i) => {
-
 
734
            const isActive = scope.currenttabindex == i ? "current" : "";
-
 
735
            tabsmenu += `
-
 
736
              <li class="${isActive}" id="tab-${CONFIG.prefix}${i}">
-
 
737
                <div class="menu-item">${area}</div>
-
 
738
              </li>`;
-
 
739
            tabcontents += `
-
 
740
              <div class="tab-content" id="${CONFIG.prefix}${i}" onpage="0" notes-count="0">
-
 
741
                <div class="notes-info">
-
 
742
                  <div class="cesa_notes-paging"></div>
-
 
743
                  <div class="count"></div>
-
 
744
                </div>
-
 
745
                <ul id="${CONFIG.prefix}${i}-list" class="cesa_notes_lists"></ul>
-
 
746
              </div>`;
-
 
747
          });
-
 
748
    
-
 
749
          // Añadir pestañas al DOM
-
 
750
          el.find(".tabs-menu").append(tabsmenu);
-
 
751
          el.find(".tab").append($(tabcontents));
-
 
752
    
835
      
753
          // Devuelve el HTML resultante
-
 
754
          $(".inline-" + CSS.cesa_notes_OPENER).html("Hola");
-
 
755
        });
-
 
Línea 756... Línea 836...
756
      
836
      
757
    },
837
    },
Línea 758... Línea 838...
758
  };
838
  };