[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/assign/feedback/editpdf/yui/src/editor/js/ -> commentmenu.js (source)

   1  var COMMENTMENUNAME = "Commentmenu",
   2      COMMENTMENU;
   3  
   4  /**
   5   * Provides an in browser PDF editor.
   6   *
   7   * @module moodle-assignfeedback_editpdf-editor
   8   */
   9  
  10  /**
  11   * COMMENTMENU
  12   * This is a drop down list of comment context functions.
  13   *
  14   * @namespace M.assignfeedback_editpdf
  15   * @class commentmenu
  16   * @constructor
  17   * @extends M.assignfeedback_editpdf.dropdown
  18   */
  19  COMMENTMENU = function(config) {
  20      COMMENTMENU.superclass.constructor.apply(this, [config]);
  21  };
  22  
  23  Y.extend(COMMENTMENU, M.assignfeedback_editpdf.dropdown, {
  24  
  25      /**
  26       * Initialise the menu.
  27       *
  28       * @method initializer
  29       * @return void
  30       */
  31      initializer: function(config) {
  32          var commentlinks,
  33              link,
  34              body,
  35              comment;
  36  
  37          comment = this.get('comment');
  38          // Build the list of menu items.
  39          commentlinks = Y.Node.create('<ul role="menu" class="assignfeedback_editpdf_menu"/>');
  40  
  41          link = Y.Node.create('<li><a tabindex="-1" href="#">' +
  42                 M.util.get_string('addtoquicklist', 'assignfeedback_editpdf') +
  43                 '</a></li>');
  44          link.on('click', comment.add_to_quicklist, comment);
  45          link.on('key', comment.add_to_quicklist, 'enter,space', comment);
  46  
  47          commentlinks.append(link);
  48  
  49          link = Y.Node.create('<li><a tabindex="-1" href="#">' +
  50                 M.util.get_string('deletecomment', 'assignfeedback_editpdf') +
  51                 '</a></li>');
  52          link.on('click', function(e) {
  53              e.preventDefault();
  54              this.menu.hide();
  55              this.remove();
  56          }, comment);
  57  
  58          link.on('key', function() {
  59              comment.menu.hide();
  60              comment.remove();
  61          }, 'enter,space', comment);
  62  
  63          commentlinks.append(link);
  64  
  65          link = Y.Node.create('<li><hr/></li>');
  66          commentlinks.append(link);
  67  
  68          // Set the accessible header text.
  69          this.set('headerText', M.util.get_string('commentcontextmenu', 'assignfeedback_editpdf'));
  70  
  71          body = Y.Node.create('<div/>');
  72  
  73          // Set the body content.
  74          body.append(commentlinks);
  75          this.set('bodyContent', body);
  76  
  77          COMMENTMENU.superclass.initializer.call(this, config);
  78      },
  79  
  80      /**
  81       * Show the menu.
  82       *
  83       * @method show
  84       * @return void
  85       */
  86      show: function() {
  87          var commentlinks = this.get('boundingBox').one('ul');
  88              commentlinks.all('.quicklist_comment').remove(true);
  89          var comment = this.get('comment');
  90  
  91          comment.deleteme = false; // Cancel the deleting of blank comments.
  92  
  93          // Now build the list of quicklist comments.
  94          Y.each(comment.editor.quicklist.comments, function(quickcomment) {
  95              var listitem = Y.Node.create('<li class="quicklist_comment"></li>'),
  96                  linkitem = Y.Node.create('<a href="#" tabindex="-1">' + quickcomment.rawtext + '</a>'),
  97                  deletelinkitem = Y.Node.create('<a href="#" tabindex="-1" class="delete_quicklist_comment">' +
  98                                                 '<img src="' + M.util.image_url('t/delete', 'core') + '" ' +
  99                                                 'alt="' + M.util.get_string('deletecomment', 'assignfeedback_editpdf') + '"/>' +
 100                                                 '</a>');
 101              listitem.append(linkitem);
 102              listitem.append(deletelinkitem);
 103  
 104              commentlinks.append(listitem);
 105  
 106              linkitem.on('click', comment.set_from_quick_comment, comment, quickcomment);
 107              linkitem.on('key', comment.set_from_quick_comment, 'space,enter', comment, quickcomment);
 108  
 109              deletelinkitem.on('click', comment.remove_from_quicklist, comment, quickcomment);
 110              deletelinkitem.on('key', comment.remove_from_quicklist, 'space,enter', comment, quickcomment);
 111          }, this);
 112  
 113          COMMENTMENU.superclass.show.call(this);
 114      }
 115  }, {
 116      NAME: COMMENTMENUNAME,
 117      ATTRS: {
 118          /**
 119           * The comment this menu is attached to.
 120           *
 121           * @attribute comment
 122           * @type M.assignfeedback_editpdf.comment
 123           * @default null
 124           */
 125          comment: {
 126              value: null
 127          }
 128  
 129      }
 130  });
 131  
 132  M.assignfeedback_editpdf = M.assignfeedback_editpdf || {};
 133  M.assignfeedback_editpdf.commentmenu = COMMENTMENU;


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1