[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

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

   1  // This file is part of Moodle - http://moodle.org/
   2  //
   3  // Moodle is free software: you can redistribute it and/or modify
   4  // it under the terms of the GNU General Public License as published by
   5  // the Free Software Foundation, either version 3 of the License, or
   6  // (at your option) any later version.
   7  //
   8  // Moodle is distributed in the hope that it will be useful,
   9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11  // GNU General Public License for more details.
  12  //
  13  // You should have received a copy of the GNU General Public License
  14  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  15  
  16  /**
  17   * Provides an in browser PDF editor.
  18   *
  19   * @module moodle-assignfeedback_editpdf-editor
  20   */
  21  
  22  /**
  23   * Class representing a line.
  24   *
  25   * @namespace M.assignfeedback_editpdf
  26   * @class annotationline
  27   * @extends M.assignfeedback_editpdf.annotation
  28   */
  29  ANNOTATIONLINE = function(config) {
  30      ANNOTATIONLINE.superclass.constructor.apply(this, [config]);
  31  };
  32  
  33  ANNOTATIONLINE.NAME = "annotationline";
  34  ANNOTATIONLINE.ATTRS = {};
  35  
  36  Y.extend(ANNOTATIONLINE, M.assignfeedback_editpdf.annotation, {
  37      /**
  38       * Draw a line annotation
  39       * @protected
  40       * @method draw
  41       * @return M.assignfeedback_editpdf.drawable
  42       */
  43      draw : function() {
  44          var drawable,
  45              shape;
  46  
  47          drawable = new M.assignfeedback_editpdf.drawable(this.editor);
  48  
  49          shape = this.editor.graphic.addShape({
  50          type: Y.Path,
  51              fill: false,
  52              stroke: {
  53                  weight: STROKEWEIGHT,
  54                  color: ANNOTATIONCOLOUR[this.colour]
  55              }
  56          });
  57  
  58          shape.moveTo(this.x, this.y);
  59          shape.lineTo(this.endx, this.endy);
  60          shape.end();
  61          drawable.shapes.push(shape);
  62          this.drawable = drawable;
  63  
  64          return ANNOTATIONLINE.superclass.draw.apply(this);
  65      },
  66  
  67      /**
  68       * Draw the in progress edit.
  69       *
  70       * @public
  71       * @method draw_current_edit
  72       * @param M.assignfeedback_editpdf.edit edit
  73       */
  74      draw_current_edit : function(edit) {
  75          var drawable = new M.assignfeedback_editpdf.drawable(this.editor),
  76              shape;
  77  
  78          shape = this.editor.graphic.addShape({
  79             type: Y.Path,
  80              fill: false,
  81              stroke: {
  82                  weight: STROKEWEIGHT,
  83                  color: ANNOTATIONCOLOUR[edit.annotationcolour]
  84              }
  85          });
  86  
  87          shape.moveTo(edit.start.x, edit.start.y);
  88          shape.lineTo(edit.end.x, edit.end.y);
  89          shape.end();
  90  
  91          drawable.shapes.push(shape);
  92  
  93          return drawable;
  94      },
  95  
  96      /**
  97       * Promote the current edit to a real annotation.
  98       *
  99       * @public
 100       * @method init_from_edit
 101       * @param M.assignfeedback_editpdf.edit edit
 102       * @return bool true if line bound is more than min width/height, else false.
 103       */
 104      init_from_edit : function(edit) {
 105          this.gradeid = this.editor.get('gradeid');
 106          this.pageno = this.editor.currentpage;
 107          this.x = edit.start.x;
 108          this.y = edit.start.y;
 109          this.endx = edit.end.x;
 110          this.endy = edit.end.y;
 111          this.colour = edit.annotationcolour;
 112          this.path = '';
 113  
 114          return !(((this.endx - this.x) === 0) && ((this.endy - this.y) === 0));
 115      }
 116  
 117  });
 118  
 119  M.assignfeedback_editpdf = M.assignfeedback_editpdf || {};
 120  M.assignfeedback_editpdf.annotationline = ANNOTATIONLINE;


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1