[ Index ]

PHP Cross Reference of Unnamed Project

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  /* global STROKEWEIGHT, ANNOTATIONCOLOUR */
  16  
  17  /**
  18   * Provides an in browser PDF editor.
  19   *
  20   * @module moodle-assignfeedback_editpdf-editor
  21   */
  22  
  23  /**
  24   * Class representing a line.
  25   *
  26   * @namespace M.assignfeedback_editpdf
  27   * @class annotationline
  28   * @extends M.assignfeedback_editpdf.annotation
  29   */
  30  var ANNOTATIONLINE = function(config) {
  31      ANNOTATIONLINE.superclass.constructor.apply(this, [config]);
  32  };
  33  
  34  ANNOTATIONLINE.NAME = "annotationline";
  35  ANNOTATIONLINE.ATTRS = {};
  36  
  37  Y.extend(ANNOTATIONLINE, M.assignfeedback_editpdf.annotation, {
  38      /**
  39       * Draw a line annotation
  40       * @protected
  41       * @method draw
  42       * @return M.assignfeedback_editpdf.drawable
  43       */
  44      draw: function() {
  45          var drawable,
  46              shape;
  47  
  48          drawable = new M.assignfeedback_editpdf.drawable(this.editor);
  49  
  50          shape = this.editor.graphic.addShape({
  51          type: Y.Path,
  52              fill: false,
  53              stroke: {
  54                  weight: STROKEWEIGHT,
  55                  color: ANNOTATIONCOLOUR[this.colour]
  56              }
  57          });
  58  
  59          shape.moveTo(this.x, this.y);
  60          shape.lineTo(this.endx, this.endy);
  61          shape.end();
  62          drawable.shapes.push(shape);
  63          this.drawable = drawable;
  64  
  65          return ANNOTATIONLINE.superclass.draw.apply(this);
  66      },
  67  
  68      /**
  69       * Draw the in progress edit.
  70       *
  71       * @public
  72       * @method draw_current_edit
  73       * @param M.assignfeedback_editpdf.edit edit
  74       */
  75      draw_current_edit: function(edit) {
  76          var drawable = new M.assignfeedback_editpdf.drawable(this.editor),
  77              shape;
  78  
  79          shape = this.editor.graphic.addShape({
  80             type: Y.Path,
  81              fill: false,
  82              stroke: {
  83                  weight: STROKEWEIGHT,
  84                  color: ANNOTATIONCOLOUR[edit.annotationcolour]
  85              }
  86          });
  87  
  88          shape.moveTo(edit.start.x, edit.start.y);
  89          shape.lineTo(edit.end.x, edit.end.y);
  90          shape.end();
  91  
  92          drawable.shapes.push(shape);
  93  
  94          return drawable;
  95      },
  96  
  97      /**
  98       * Promote the current edit to a real annotation.
  99       *
 100       * @public
 101       * @method init_from_edit
 102       * @param M.assignfeedback_editpdf.edit edit
 103       * @return bool true if line bound is more than min width/height, else false.
 104       */
 105      init_from_edit: function(edit) {
 106          this.gradeid = this.editor.get('gradeid');
 107          this.pageno = this.editor.currentpage;
 108          this.x = edit.start.x;
 109          this.y = edit.start.y;
 110          this.endx = edit.end.x;
 111          this.endy = edit.end.y;
 112          this.colour = edit.annotationcolour;
 113          this.path = '';
 114  
 115          return !(((this.endx - this.x) === 0) && ((this.endy - this.y) === 0));
 116      }
 117  
 118  });
 119  
 120  M.assignfeedback_editpdf = M.assignfeedback_editpdf || {};
 121  M.assignfeedback_editpdf.annotationline = ANNOTATIONLINE;


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