Proyectos de Subversion Moodle

Rev

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

Rev 999 Rev 1000
Línea 1... Línea 1...
1
define([
1
define([
2
  "jquery",
2
  "jquery",
3
  "core/yui",
3
  "core/yui",
4
  "core/str",
4
  "core/str"
5
  "core/config",
-
 
6
  "core/notification",
-
 
7
  "core/modal_factory",
-
 
8
], function ($, Y, str, config, notification, ModalFactory) {
5
], function ($, Y, str) {
9
  var CONFIG;
6
  var CONFIG;
10
  var NODES = {
7
  var NODES = {
11
    DELETE_ICON: '<span class="delete">&#x274C;</span>',
8
    DELETE_ICON: '<span class="delete">&#x274C;</span>',
12
  };
9
  };
13
  var SELECTORS = {
10
  var SELECTORS = {
Línea 141... Línea 138...
141
      if (args.form) {
138
      if (args.form) {
142
        cfg.form = args.form;
139
        cfg.form = args.form;
143
      }
140
      }
144
      Y.io(this.api, cfg);
141
      Y.io(this.api, cfg);
145
    },
142
    },
146
 
-
 
147
    printcesa_notes: function (e) {
143
    printcesa_notes: function (e) {
148
      e.preventDefault();
144
      e.preventDefault();
149
      let note_content_input = $("#id_mynotecontent-" + CONFIG.instanceid);
145
      let note_content_input = $("#id_mynotecontent-" + CONFIG.instanceid);
150
      let arg = {
146
      let arg = {
151
        action: "print",
147
        action: "print",
Línea 167... Línea 163...
167
            backgroundImage: "",
163
            backgroundImage: "",
168
          });
164
          });
169
        },
165
        },
170
      });
166
      });
171
    },
167
    },
172
 
-
 
173
    savecesa_notes: function (e) {
168
    savecesa_notes: function (e) {
174
      e.preventDefault();
169
      e.preventDefault();
175
      var scope = this;
170
      var scope = this;
Línea 176... Línea 171...
176
 
171
 
Línea 642... Línea 637...
642
            });
637
            });
643
          }
638
          }
644
        }
639
        }
645
      );
640
      );
646
    },
641
    },
647
    /* displayDialogue: function (e) {
-
 
648
      var scope = cesa_notes;
-
 
649
      if (panel === null) {
-
 
650
        str
-
 
651
          .get_strings([
-
 
652
            { key: "cesa_notes", component: "block_cesa_notes" },
-
 
653
            { key: "characterlimit", component: "block_cesa_notes" },
-
 
654
            { key: "save", component: "block_cesa_notes" },
-
 
655
            { key: "cancel" },
-
 
656
            {
-
 
657
              key: "cesa_notessavedundertab",
-
 
658
              component: "block_cesa_notes",
-
 
659
              param: CONFIG.contextareas[scope.currenttabindex],
-
 
660
            },
-
 
661
            { key: "placeholdercontent", component: "block_cesa_notes" },
-
 
662
          ])
-
 
663
          .done(function (s) {
-
 
664
            // Create basic tab structure
-
 
665
 
-
 
666
            let deleteModal = `<div id="cesa_notes_delete_modal">
-
 
667
                                        <div class="cesa_notes_delete_modal_content">
-
 
668
                                            <p>¿Estás seguro de que quieres eliminar este apunte?</p>
-
 
669
                                            <button id="cesa_notes_modal_cancel_delete">Cancelar</button>
-
 
670
                                            <button id="cesa_notes_modal_accept_delete">Eliminar</button>
-
 
671
                                        </div>
-
 
672
                                        </div>`;
-
 
673
            var el = $("<div></div>").append(
-
 
674
              $(
-
 
675
                '<div id="' +
-
 
676
                  CSS.cesa_notes_BASE +
-
 
677
                  '" class="' +
-
 
678
                  CSS.cesa_notes_BASE +
-
 
679
                  '">' +
-
 
680
                  deleteModal +
-
 
681
                  "</div>"
-
 
682
              )
-
 
683
                .append(
-
 
684
                  '<div class="inputarea"><div class="responsetext"></div><div class="cesa-notes-limit" id="addmynote-label-' +
-
 
685
                    CONFIG.instanceid +
-
 
686
                    '">' +
-
 
687
                    s[1] +
-
 
688
                    " " +
-
 
689
                    CONFIG.maxallowedcharacters +
-
 
690
                    '<span class="warning"></span></div>' +
-
 
691
                    '<div class="textarea"><textarea id="id_mynotecontent-' +
-
 
692
                    CONFIG.instanceid +
-
 
693
                    '" name="mynotecontent" rows="2">' +
-
 
694
                    s[5] +
-
 
695
                    "</textarea></div>" +
-
 
696
                    '<p class="notesavedhint">' +
-
 
697
                    s[4] +
-
 
698
                    "</p>" +
-
 
699
                    '<p class="cesa_notes_buttons_container"><button class="j-delete-cesa-note">Eliminar</button><input type="submit" id="addmynote_submit"/> </p>' +
-
 
700
                    '<p class="cesa_note_bottom_container"><a class="cesa_notes_print" target="_blank" href="' +
-
 
701
                    CONFIG.printapi +
-
 
702
                    '">Imprimir notas</a> </p>' +
-
 
703
                    "</div>"
-
 
704
                )
-
 
705
                .append($('<ul class="tabs-menu"></ul>'))
-
 
706
                .append($('<div class="tab"></div>'))
-
 
707
            );
-
 
708
            el.find("#addmynote_submit").attr("value", s[2]);
-
 
709
            el.find("#addmynote_cancel").attr("value", s[3]);
-
 
710
            var tabsmenu = "";
-
 
711
            var tabcontents = "";
-
 
712
            var i = "";
-
 
713
            for (i in CONFIG.contextareas) {
-
 
714
              if (scope.currenttabindex == i) {
-
 
715
                tabsmenu +=
-
 
716
                  '<li class="current" id="tab-' +
-
 
717
                  CONFIG.prefix +
-
 
718
                  i +
-
 
719
                  '"><div class="menu-item">' +
-
 
720
                  CONFIG.contextareas[i] +
-
 
721
                  "</div></li>";
-
 
722
              } else {
-
 
723
                tabsmenu +=
-
 
724
                  '<li class="" id="tab-' +
-
 
725
                  CONFIG.prefix +
-
 
726
                  i +
-
 
727
                  '"><div class="menu-item">' +
-
 
728
                  CONFIG.contextareas[i] +
-
 
729
                  "</div></li>";
-
 
730
              }
-
 
731
              tabcontents +=
-
 
732
                '<div class="tab-content" id="' +
-
 
733
                CONFIG.prefix +
-
 
734
                i +
-
 
735
                '" onpage="0" notes-count="0">' +
-
 
736
                '<div class="notes-info"><div class="cesa_notes-paging"></div><div class="count"></div></div>' +
-
 
737
                '<ul id="' +
-
 
738
                CONFIG.prefix +
-
 
739
                i +
-
 
740
                '-list" class="cesa_notes_lists"></ul>' +
-
 
741
                "</div>";
-
 
742
            }
-
 
743
            el.find(".tabs-menu").append(tabsmenu);
-
 
744
            el.find(".tab").append($(tabcontents));
-
 
745
            ModalFactory.create({
-
 
746
              title: s[0],
-
 
747
              body: el.html(),
-
 
748
            }).then(function (modal) {
-
 
749
              if (initnotes === null) {
-
 
750
                initnotes = true;
-
 
751
                // Get initial notes
-
 
752
                scope.getcesa_notes(0);
-
 
753
                $(SELECTORS.cesa_notes_BASE)
-
 
754
                  .find(scope.currenttab)
-
 
755
                  .attr("data-loaded", "true");
-
 
756
                $(SELECTORS.cesa_notes_BASE)
-
 
757
                  .find(scope.currenttab)
-
 
758
                  .css("display", "block");
-
 
759
              }
-
 
760
 
-
 
761
              let root = modal.getRoot();
-
 
762
 
-
 
763
              root.addClass("modal_cesa_notes_root");
-
 
764
 
-
 
765
              panel = modal;
-
 
766
              panel.show();
-
 
767
              scope.registerActions();
-
 
768
            });
-
 
769
 
-
 
770
            /*if (initnotes === null) {
-
 
771
                        initnotes = true;                        
-
 
772
                        // Get initial notes
-
 
773
                        scope.getcesa_notes(0);
-
 
774
                        $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).attr('data-loaded', "true");
-
 
775
                        $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).css('display', 'block');
-
 
776
                    }
-
 
777
 
-
 
778
                    panel.show();*/
-
 
779
    /*Y.use('moodle-core-notification-dialogue', function() {
-
 
780
                
-
 
781
                 // TODO: CESA_NOTES Cambiar esto para que no use yui sino https://docs.moodle.org/dev/AMD_Modal
-
 
782
                 
-
 
783
                panel = new M.core.dialogue({
-
 
784
                    draggable: true,
-
 
785
                    modal: true,
-
 
786
                    closeButton: true,
-
 
787
                    headerContent: M.util.get_string('cesa_notes', 'block_cesa_notes'),
-
 
788
                    responsive: true,
-
 
789
                    classname: 'testing'
-
 
790
                });
-
 
791
 
-
 
792
                panel.set('bodyContent', el.html());
-
 
793
                if (initnotes === null) {
-
 
794
                    initnotes = true;                        
-
 
795
                    // Get initial notes
-
 
796
                    scope.getcesa_notes(0);
-
 
797
                    $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).attr('data-loaded', "true");
-
 
798
                    $(SELECTORS.cesa_notes_BASE).find(scope.currenttab).css('display', 'block');
-
 
799
                }
-
 
800
                panel.show();
-
 
801
            });
-
 
802
    //scope.registerActions();
-
 
803
  });
-
 
804
} else {
-
 
805
panel.show();
-
 
806
}
-
 
807
}, */
-
 
808
    /**
642
    /**
809
     * Initialize cesa_notes
643
     * Initialize cesa_notes
810
     * @access public
644
     * @access public
811
     * @param {int} instanceid
645
     * @param {int} instanceid
812
     * @param {int} contextid
646
     * @param {int} contextid
Línea 938... Línea 772...
938
          el.find(".tabs-menu").append(tabsmenu);
772
          el.find(".tabs-menu").append(tabsmenu);
939
          el.find(".tab").append($(tabcontents));
773
          el.find(".tab").append($(tabcontents));
Línea 940... Línea 774...
940
 
774
 
Línea 941... Línea 775...
941
          $(SELECTORS.cesa_notes_ROOT).html(el.html());
775
          $(SELECTORS.cesa_notes_ROOT).html(el.html());
942
 
776
 
943
          /* if (initnotes === null) {
777
          if (initnotes === null) {
944
            initnotes = true;
778
            initnotes = true;
945
            // Get initial notes
779
            // Get initial notes
946
            scope.getcesa_notes(0);
780
            scope.getcesa_notes(0);
947
            $(SELECTORS.cesa_notes_BASE)
781
            $(SELECTORS.cesa_notes_BASE)
948
              .find(scope.currenttab)
782
              .find(scope.currenttab)
949
              .attr("data-loaded", "true");
783
              .attr("data-loaded", "true");
950
            $(SELECTORS.cesa_notes_BASE)
784
            $(SELECTORS.cesa_notes_BASE)
951
              .find(scope.currenttab)
785
              .find(scope.currenttab)
952
              .css("display", "block");
786
              .css("display", "block");
953
          }
787
          }
954
  
788
 
Línea 955... Línea 789...
955
          scope.registerActions(); */
789
          scope.registerActions();
956
        });
790
        });