MDL-42571 assignfeedback_editpdf: Fixed second PDF view
authorBence Laky <b.laky@intrallect.com>
Thu, 12 Nov 2015 10:21:39 +0000 (10:21 +0000)
committerBence Laky <b.laky@intrallect.com>
Thu, 12 Nov 2015 14:16:17 +0000 (14:16 +0000)
mod/assign/feedback/editpdf/version.php
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor.js
mod/assign/feedback/editpdf/yui/src/editor/js/annotation.js
mod/assign/feedback/editpdf/yui/src/editor/js/annotationstamp.js
mod/assign/feedback/editpdf/yui/src/editor/js/comment.js
mod/assign/feedback/editpdf/yui/src/editor/js/commentsearch.js
mod/assign/feedback/editpdf/yui/src/editor/js/drawable.js
mod/assign/feedback/editpdf/yui/src/editor/js/editor.js
mod/assign/feedback/editpdf/yui/src/editor/js/globals.js

index d9cc4ba..42fd727 100644 (file)
@@ -24,7 +24,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2015051100;
+$plugin->version   = 2015111200;
 $plugin->requires  = 2015050500;
 $plugin->component = 'assignfeedback_editpdf';
 
index 565dd2d..50c827f 100644 (file)
Binary files a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js and b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js differ
index e5e4732..6848d48 100644 (file)
Binary files a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js and b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js differ
index 565dd2d..50c827f 100644 (file)
Binary files a/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor.js and b/mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor.js differ
index 3ccb9ac..5415add 100644 (file)
@@ -170,8 +170,8 @@ Y.extend(ANNOTATION, Y.Base, {
      */
     draw_highlight : function() {
         var bounds,
-            drawingregion = Y.one(SELECTOR.DRAWINGREGION),
-            offsetcanvas = Y.one(SELECTOR.DRAWINGCANVAS).getXY(),
+            drawingregion = this.editor.get_dialogue_element(SELECTOR.DRAWINGREGION),
+            offsetcanvas = this.editor.get_dialogue_element(SELECTOR.DRAWINGCANVAS).getXY(),
             shape;
 
         if (this.editor.currentannotation === this) {
index df1c0bf..d4597ec 100644 (file)
@@ -42,7 +42,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
      */
     draw : function() {
         var drawable = new M.assignfeedback_editpdf.drawable(this.editor),
-            drawingregion = Y.one(SELECTOR.DRAWINGREGION),
+            drawingregion = this.editor.get_dialogue_element(SELECTOR.DRAWINGREGION),
             node,
             position;
 
@@ -84,7 +84,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
     draw_current_edit : function(edit) {
         var bounds = new M.assignfeedback_editpdf.rect(),
             drawable = new M.assignfeedback_editpdf.drawable(this.editor),
-            drawingregion = Y.one(SELECTOR.DRAWINGREGION),
+            drawingregion = this.editor.get_dialogue_element(SELECTOR.DRAWINGREGION),
             node,
             position;
 
index c37c8ca..bdb96f9 100644 (file)
@@ -159,7 +159,7 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
     this.draw = function(focus) {
         var drawable = new M.assignfeedback_editpdf.drawable(this.editor),
             node,
-            drawingregion = Y.one(SELECTOR.DRAWINGREGION),
+            drawingregion = this.editor.get_dialogue_element(SELECTOR.DRAWINGREGION),
             container,
             menu,
             position,
index 0dece81..e46c263 100644 (file)
@@ -73,8 +73,8 @@ Y.extend(COMMENTSEARCH, M.core.dialogue, {
             commentslist,
             filtertext;
 
-        filternode = Y.one(SELECTOR.SEARCHFILTER);
-        commentslist = Y.one(SELECTOR.SEARCHCOMMENTSLIST);
+        filternode = this.get('editor').get_dialogue_element(SELECTOR.SEARCHFILTER);
+        commentslist = this.get('editor').get_dialogue_element(SELECTOR.SEARCHCOMMENTSLIST);
 
         filtertext = filternode.get('value');
 
index 3daec87..21e368c 100644 (file)
@@ -100,7 +100,7 @@ var DRAWABLE = function(editor) {
     this.store_position = function(container, x, y) {
         var drawingregion, scrollx, scrolly;
 
-        drawingregion = Y.one(SELECTOR.DRAWINGREGION);
+        drawingregion = this.editor.get_dialogue_element(SELECTOR.DRAWINGREGION);
         scrollx = parseInt(drawingregion.get('scrollLeft'), 10);
         scrolly = parseInt(drawingregion.get('scrollTop'), 10);
         container.setData('x', x + scrollx);
index 33c915a..1c1904e 100644 (file)
@@ -219,7 +219,7 @@ EDITOR.prototype = {
         var button, currenttoolnode, imgurl;
 
         // Initalise the colour buttons.
-        button = Y.one(SELECTOR.COMMENTCOLOURBUTTON);
+        button = this.get_dialogue_element(SELECTOR.COMMENTCOLOURBUTTON);
 
         imgurl = M.util.image_url('background_colour_' + this.currentedit.commentcolour, 'assignfeedback_editpdf');
         button.one('img').setAttribute('src', imgurl);
@@ -230,15 +230,15 @@ EDITOR.prototype = {
             button.one('img').setStyle('borderStyle', 'solid');
         }
 
-        button = Y.one(SELECTOR.ANNOTATIONCOLOURBUTTON);
+        button = this.get_dialogue_element(SELECTOR.ANNOTATIONCOLOURBUTTON);
         imgurl = M.util.image_url('colour_' + this.currentedit.annotationcolour, 'assignfeedback_editpdf');
         button.one('img').setAttribute('src', imgurl);
 
-        currenttoolnode = Y.one(TOOLSELECTOR[this.currentedit.tool]);
+        currenttoolnode = this.get_dialogue_element(TOOLSELECTOR[this.currentedit.tool]);
         currenttoolnode.addClass('assignfeedback_editpdf_selectedbutton');
         currenttoolnode.setAttribute('aria-pressed', 'true');
 
-        button = Y.one(SELECTOR.STAMPSBUTTON);
+        button = this.get_dialogue_element(SELECTOR.STAMPSBUTTON);
         button.one('img').setAttrs({'src': this.get_stamp_image_url(this.currentedit.stamp),
                                     'height': '16',
                                     'width': '16'});
@@ -249,7 +249,7 @@ EDITOR.prototype = {
      * @method get_canvas_bounds
      */
     get_canvas_bounds : function() {
-        var canvas = Y.one(SELECTOR.DRAWINGCANVAS),
+        var canvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS),
             offsetcanvas = canvas.getXY(),
             offsetleft = offsetcanvas[0],
             offsettop = offsetcanvas[1],
@@ -308,12 +308,12 @@ EDITOR.prototype = {
             // Add custom class for styling.
             this.dialogue.get('boundingBox').addClass(CSS.DIALOGUE);
 
-            this.loadingicon = Y.one(SELECTOR.LOADINGICON);
+            this.loadingicon = this.get_dialogue_element(SELECTOR.LOADINGICON);
 
-            drawingcanvas = Y.one(SELECTOR.DRAWINGCANVAS);
+            drawingcanvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS);
             this.graphic = new Y.Graphic({render : SELECTOR.DRAWINGCANVAS});
 
-            drawingregion = Y.one(SELECTOR.DRAWINGREGION);
+            drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
             drawingregion.on('scroll', this.move_canvas, this);
 
             if (!this.get('readonly')) {
@@ -393,7 +393,7 @@ EDITOR.prototype = {
                             var pagetotal = this.get('pagetotal');
 
                             // Update the progress bar.
-                            var progressbarcontainer = Y.one(SELECTOR.PROGRESSBARCONTAINER);
+                            var progressbarcontainer = this.get_dialogue_element(SELECTOR.PROGRESSBARCONTAINER);
                             var progressbar = progressbarcontainer.one('.bar');
                             if (progressbar) {
                                 // Calculate progress.
@@ -520,7 +520,7 @@ EDITOR.prototype = {
             picker,
             filename;
 
-        searchcommentsbutton = Y.one(SELECTOR.SEARCHCOMMENTSBUTTON);
+        searchcommentsbutton = this.get_dialogue_element(SELECTOR.SEARCHCOMMENTSBUTTON);
         searchcommentsbutton.on('click', this.open_search_comments, this);
         searchcommentsbutton.on('key', this.open_search_comments, 'down:13', this);
 
@@ -529,7 +529,7 @@ EDITOR.prototype = {
         }
         // Setup the tool buttons.
         Y.each(TOOLSELECTOR, function(selector, tool) {
-            toolnode = Y.one(selector);
+            toolnode = this.get_dialogue_element(selector);
             toolnode.on('click', this.handle_tool_button, this, tool);
             toolnode.on('key', this.handle_tool_button, 'down:13', this, tool);
             toolnode.setAttribute('aria-pressed', 'false');
@@ -537,7 +537,7 @@ EDITOR.prototype = {
 
         // Set the default tool.
 
-        commentcolourbutton = Y.one(SELECTOR.COMMENTCOLOURBUTTON);
+        commentcolourbutton = this.get_dialogue_element(SELECTOR.COMMENTCOLOURBUTTON);
         picker = new M.assignfeedback_editpdf.colourpicker({
             buttonNode: commentcolourbutton,
             colours: COMMENTCOLOUR,
@@ -553,7 +553,7 @@ EDITOR.prototype = {
             context: this
         });
 
-        annotationcolourbutton = Y.one(SELECTOR.ANNOTATIONCOLOURBUTTON);
+        annotationcolourbutton = this.get_dialogue_element(SELECTOR.ANNOTATIONCOLOURBUTTON);
         picker = new M.assignfeedback_editpdf.colourpicker({
             buttonNode: annotationcolourbutton,
             iconprefix: 'colour_',
@@ -575,11 +575,11 @@ EDITOR.prototype = {
 
         stampfiles = this.get('stampfiles');
         if (stampfiles.length <= 0) {
-            Y.one(TOOLSELECTOR.stamp).ancestor().hide();
+            this.get_dialogue_element(TOOLSELECTOR.stamp).ancestor().hide();
         } else {
             filename = stampfiles[0].substr(stampfiles[0].lastIndexOf('/') + 1);
             this.currentedit.stamp = filename;
-            currentstampbutton = Y.one(SELECTOR.STAMPSBUTTON);
+            currentstampbutton = this.get_dialogue_element(SELECTOR.STAMPSBUTTON);
 
             picker = new M.assignfeedback_editpdf.stamppicker({
                 buttonNode: currentstampbutton,
@@ -612,7 +612,7 @@ EDITOR.prototype = {
         e.preventDefault();
 
         // Change style of the pressed button.
-        currenttoolnode = Y.one(TOOLSELECTOR[this.currentedit.tool]);
+        currenttoolnode = this.get_dialogue_element(TOOLSELECTOR[this.currentedit.tool]);
         currenttoolnode.removeClass('assignfeedback_editpdf_selectedbutton');
         currenttoolnode.setAttribute('aria-pressed', 'false');
         this.currentedit.tool = tool;
@@ -672,6 +672,15 @@ EDITOR.prototype = {
 
         return drawable;
     },
+    
+    /**
+     * Find an element within the dialogue.
+     * @protected
+     * @method get_dialogue_element
+     */
+    get_dialogue_element : function(selector) {
+        return this.dialogue.get('boundingBox').one(selector);
+    },
 
     /**
      * Redraw the active edit.
@@ -693,7 +702,7 @@ EDITOR.prototype = {
      */
     edit_start : function(e) {
         e.preventDefault();
-        var canvas = Y.one(SELECTOR.DRAWINGCANVAS),
+        var canvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS),
             offset = canvas.getXY(),
             scrolltop = canvas.get('docScrollY'),
             scrollleft = canvas.get('docScrollX'),
@@ -764,7 +773,7 @@ EDITOR.prototype = {
     edit_move : function(e) {
         e.preventDefault();
         var bounds = this.get_canvas_bounds(),
-            canvas = Y.one(SELECTOR.DRAWINGCANVAS),
+            canvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS),
             clientpoint = new M.assignfeedback_editpdf.point(e.clientX + canvas.get('docScrollX'),
                                                              e.clientY + canvas.get('docScrollY')),
             point = this.get_canvas_coordinates(clientpoint);
@@ -861,7 +870,7 @@ EDITOR.prototype = {
         if (drawregionheight < 100) {
             drawregionheight = 100;
         }
-        drawingregion = Y.one(SELECTOR.DRAWINGREGION);
+        drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
         drawingregion.setStyle('maxHeight', drawregionheight +'px');
         this.redraw();
         return true;
@@ -921,7 +930,8 @@ EDITOR.prototype = {
                         if (jsondata.error) {
                             return new M.core.ajaxException(jsondata);
                         }
-                        Y.one(SELECTOR.UNSAVEDCHANGESDIV).addClass('haschanges');
+                        Y.one('#' + this.get('linkid')).siblings(SELECTOR.UNSAVEDCHANGESDIV)
+                            .item(0).addClass('haschanges');
                     } catch (e) {
                         return new M.core.exception(e);
                     }
@@ -985,13 +995,13 @@ EDITOR.prototype = {
      * @method change_page
      */
     change_page : function() {
-        var drawingcanvas = Y.one(SELECTOR.DRAWINGCANVAS),
+        var drawingcanvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS),
             page,
             previousbutton,
             nextbutton;
 
-        previousbutton = Y.one(SELECTOR.PREVIOUSBUTTON);
-        nextbutton = Y.one(SELECTOR.NEXTBUTTON);
+        previousbutton = this.get_dialogue_element(SELECTOR.PREVIOUSBUTTON);
+        nextbutton = this.get_dialogue_element(SELECTOR.NEXTBUTTON);
 
         if (this.currentpage > 0) {
             previousbutton.removeAttribute('disabled');
@@ -1011,7 +1021,7 @@ EDITOR.prototype = {
         drawingcanvas.setStyle('height', page.height + 'px');
 
         // Update page select.
-        Y.one(SELECTOR.PAGESELECT).set('value', this.currentpage);
+        this.get_dialogue_element(SELECTOR.PAGESELECT).set('value', this.currentpage);
 
         this.resize(); // Internally will call 'redraw', after checking the dialogue size.
     },
@@ -1029,7 +1039,7 @@ EDITOR.prototype = {
             previousbutton,
             nextbutton;
 
-        pageselect = Y.one(SELECTOR.PAGESELECT);
+        pageselect = this.get_dialogue_element(SELECTOR.PAGESELECT);
 
         var options = pageselect.all('option');
         if (options.size() <= 1) {
@@ -1046,8 +1056,8 @@ EDITOR.prototype = {
             this.change_page();
         }, this);
 
-        previousbutton = Y.one(SELECTOR.PREVIOUSBUTTON);
-        nextbutton = Y.one(SELECTOR.NEXTBUTTON);
+        previousbutton = this.get_dialogue_element(SELECTOR.PREVIOUSBUTTON);
+        nextbutton = this.get_dialogue_element(SELECTOR.NEXTBUTTON);
 
         previousbutton.on('click', this.previous_page, this);
         previousbutton.on('key', this.previous_page, 'down:13', this);
@@ -1091,7 +1101,7 @@ EDITOR.prototype = {
     move_canvas: function() {
         var drawingregion, x, y, i;
 
-        drawingregion = Y.one(SELECTOR.DRAWINGREGION);
+        drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
         x = parseInt(drawingregion.get('scrollLeft'), 10);
         y = parseInt(drawingregion.get('scrollTop'), 10);
 
index 7eab77e..b3f6980 100644 (file)
@@ -24,23 +24,23 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
         DIALOGUE : 'assignfeedback_editpdf_widget'
     },
     SELECTOR = {
-        PREVIOUSBUTTON : '.' + CSS.DIALOGUE + ' .navigate-previous-button',
-        NEXTBUTTON : '.' + CSS.DIALOGUE + ' .navigate-next-button',
-        SEARCHCOMMENTSBUTTON : '.' + CSS.DIALOGUE + ' .searchcommentsbutton',
+        PREVIOUSBUTTON :  '.navigate-previous-button',
+        NEXTBUTTON :  ' .navigate-next-button',
+        SEARCHCOMMENTSBUTTON : '.searchcommentsbutton',
         SEARCHFILTER : '.assignfeedback_editpdf_commentsearch input',
         SEARCHCOMMENTSLIST : '.assignfeedback_editpdf_commentsearch ul',
-        PAGESELECT : '.' + CSS.DIALOGUE + ' .navigate-page-select',
-        LOADINGICON : '.' + CSS.DIALOGUE + ' .loading',
-        PROGRESSBARCONTAINER : '.' + CSS.DIALOGUE + ' .progress-info.progress-striped',
-        DRAWINGREGION : '.' + CSS.DIALOGUE + ' .drawingregion',
-        DRAWINGCANVAS : '.' + CSS.DIALOGUE + ' .drawingcanvas',
-        SAVE : '.' + CSS.DIALOGUE + ' .savebutton',
-        COMMENTCOLOURBUTTON : '.' + CSS.DIALOGUE + ' .commentcolourbutton',
-        COMMENTMENU : ' .commentdrawable a',
-        ANNOTATIONCOLOURBUTTON : '.' + CSS.DIALOGUE + ' .annotationcolourbutton',
-        DELETEANNOTATIONBUTTON : '.' + CSS.DIALOGUE + ' .deleteannotationbutton',
+        PAGESELECT : '.navigate-page-select',
+        LOADINGICON : '.loading',
+        PROGRESSBARCONTAINER : '.progress-info.progress-striped',
+        DRAWINGREGION : '.drawingregion',
+        DRAWINGCANVAS : '.drawingcanvas',
+        SAVE : '.savebutton',
+        COMMENTCOLOURBUTTON : '.commentcolourbutton',
+        COMMENTMENU : '.commentdrawable a',
+        ANNOTATIONCOLOURBUTTON :  '.annotationcolourbutton',
+        DELETEANNOTATIONBUTTON : '.deleteannotationbutton',
         UNSAVEDCHANGESDIV : '.assignfeedback_editpdf_unsavedchanges',
-        STAMPSBUTTON : '.' + CSS.DIALOGUE + ' .currentstampbutton',
+        STAMPSBUTTON : '.currentstampbutton',
         DIALOGUE : '.' + CSS.DIALOGUE
     },
     SELECTEDBORDERCOLOUR = 'rgba(200, 200, 255, 0.9)',
@@ -64,13 +64,13 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
     },
     CLICKTIMEOUT = 300,
     TOOLSELECTOR = {
-        'comment': '.' + CSS.DIALOGUE + ' .commentbutton',
-        'pen': '.' + CSS.DIALOGUE + ' .penbutton',
-        'line': '.' + CSS.DIALOGUE + ' .linebutton',
-        'rectangle': '.' + CSS.DIALOGUE + ' .rectanglebutton',
-        'oval': '.' + CSS.DIALOGUE + ' .ovalbutton',
-        'stamp': '.' + CSS.DIALOGUE + ' .stampbutton',
-        'select': '.' + CSS.DIALOGUE + ' .selectbutton',
-        'highlight': '.' + CSS.DIALOGUE + ' .highlightbutton'
+        'comment': '.commentbutton',
+        'pen': '.penbutton',
+        'line': '.linebutton',
+        'rectangle': '.rectanglebutton',
+        'oval': '.ovalbutton',
+        'stamp': '.stampbutton',
+        'select': '.selectbutton',
+        'highlight': '.highlightbutton'
     },
     STROKEWEIGHT = 4;