Skip to content

Commit

Permalink
MDL-42352 assignfeedback_editpdf - prevent scrolling when clicking on…
Browse files Browse the repository at this point in the history
… buttons
  • Loading branch information
davosmith committed Oct 22, 2013
1 parent 129ceb5 commit 114913e
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 25 deletions.
Expand Up @@ -667,9 +667,11 @@ Y.extend(ANNOTATION, Y.Base, {
* @method remove
* @param event
*/
remove : function() {
remove : function(e) {
var annotations;

e.preventDefault();

annotations = this.editor.pages[this.editor.currentpage].annotations;
for (i = 0; i < annotations.length; i++) {
if (annotations[i] === this) {
Expand Down Expand Up @@ -1577,7 +1579,7 @@ Y.extend(DROPDOWN, M.core.dialogue, {
}
}, this);

button.on('click', this.show, this);
button.on('click', function(e) {e.preventDefault(); this.show();}, this);
button.on('key', this.show, 'enter,space', this);
},

Expand Down Expand Up @@ -1682,6 +1684,8 @@ Y.extend(COLOURPICKER, M.assignfeedback_editpdf.dropdown, {
COLOURPICKER.superclass.initializer.call(this, config);
},
callback_handler : function(e) {
e.preventDefault();

var callback = this.get('callback'),
callbackcontext = this.get('context'),
bind;
Expand Down Expand Up @@ -1798,6 +1802,7 @@ Y.extend(STAMPPICKER, M.assignfeedback_editpdf.dropdown, {
STAMPPICKER.superclass.initializer.call(this, config);
},
callback_handler : function(e) {
e.preventDefault();
var callback = this.get('callback'),
callbackcontext = this.get('context'),
bind;
Expand Down Expand Up @@ -1890,7 +1895,7 @@ Y.extend(COMMENTMENU, M.assignfeedback_editpdf.dropdown, {
commentlinks.append(link);

link = Y.Node.create('<li><a tabindex="-1" href="#">' + M.util.get_string('deletecomment', 'assignfeedback_editpdf') + '</a></li>');
link.on('click', function() { comment.menu.hide(); comment.remove(); }, comment);
link.on('click', function(e) { e.preventDefault(); this.menu.hide(); this.remove(); }, comment);
link.on('key', function() { comment.menu.hide(); comment.remove(); }, 'enter,space', comment);

commentlinks.append(link);
Expand Down Expand Up @@ -2056,6 +2061,7 @@ Y.extend(COMMENTSEARCH, M.core.dialogue, {
* @method focus_on_comment
*/
focus_on_comment : function(e) {
e.preventDefault();
var target = e.target.ancestor('li'),
comment = target.getData('comment'),
editor = this.get('editor');
Expand Down Expand Up @@ -2447,6 +2453,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @method remove_from_quicklist
*/
this.remove_from_quicklist = function(e, quickcomment) {
e.preventDefault();

this.menu.hide();

this.editor.quicklist.remove(quickcomment);
Expand All @@ -2460,6 +2468,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @method set_from_quick_comment
*/
this.set_from_quick_comment = function(e, quickcomment) {
e.preventDefault();

this.menu.hide();

this.rawtext = quickcomment.rawtext;
Expand All @@ -2477,7 +2487,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @protected
* @method add_to_quicklist
*/
this.add_to_quicklist = function() {
this.add_to_quicklist = function(e) {
e.preventDefault();
this.menu.hide();
this.editor.quicklist.add(this);
};
Expand Down Expand Up @@ -3740,7 +3751,8 @@ EDITOR.prototype = {
* @protected
* @method previous_page
*/
previous_page : function() {
previous_page : function(e) {
e.preventDefault();
this.currentpage--;
if (this.currentpage < 0) {
this.currentpage = 0;
Expand All @@ -3753,7 +3765,8 @@ EDITOR.prototype = {
* @protected
* @method next_page
*/
next_page : function() {
next_page : function(e) {
e.preventDefault();
this.currentpage++;
if (this.currentpage >= this.pages.length) {
this.currentpage = this.pages.length - 1;
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -667,9 +667,11 @@ Y.extend(ANNOTATION, Y.Base, {
* @method remove
* @param event
*/
remove : function() {
remove : function(e) {
var annotations;

e.preventDefault();

annotations = this.editor.pages[this.editor.currentpage].annotations;
for (i = 0; i < annotations.length; i++) {
if (annotations[i] === this) {
Expand Down Expand Up @@ -1577,7 +1579,7 @@ Y.extend(DROPDOWN, M.core.dialogue, {
}
}, this);

button.on('click', this.show, this);
button.on('click', function(e) {e.preventDefault(); this.show();}, this);
button.on('key', this.show, 'enter,space', this);
},

Expand Down Expand Up @@ -1682,6 +1684,8 @@ Y.extend(COLOURPICKER, M.assignfeedback_editpdf.dropdown, {
COLOURPICKER.superclass.initializer.call(this, config);
},
callback_handler : function(e) {
e.preventDefault();

var callback = this.get('callback'),
callbackcontext = this.get('context'),
bind;
Expand Down Expand Up @@ -1798,6 +1802,7 @@ Y.extend(STAMPPICKER, M.assignfeedback_editpdf.dropdown, {
STAMPPICKER.superclass.initializer.call(this, config);
},
callback_handler : function(e) {
e.preventDefault();
var callback = this.get('callback'),
callbackcontext = this.get('context'),
bind;
Expand Down Expand Up @@ -1890,7 +1895,7 @@ Y.extend(COMMENTMENU, M.assignfeedback_editpdf.dropdown, {
commentlinks.append(link);

link = Y.Node.create('<li><a tabindex="-1" href="#">' + M.util.get_string('deletecomment', 'assignfeedback_editpdf') + '</a></li>');
link.on('click', function() { comment.menu.hide(); comment.remove(); }, comment);
link.on('click', function(e) { e.preventDefault(); this.menu.hide(); this.remove(); }, comment);
link.on('key', function() { comment.menu.hide(); comment.remove(); }, 'enter,space', comment);

commentlinks.append(link);
Expand Down Expand Up @@ -2056,6 +2061,7 @@ Y.extend(COMMENTSEARCH, M.core.dialogue, {
* @method focus_on_comment
*/
focus_on_comment : function(e) {
e.preventDefault();
var target = e.target.ancestor('li'),
comment = target.getData('comment'),
editor = this.get('editor');
Expand Down Expand Up @@ -2447,6 +2453,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @method remove_from_quicklist
*/
this.remove_from_quicklist = function(e, quickcomment) {
e.preventDefault();

this.menu.hide();

this.editor.quicklist.remove(quickcomment);
Expand All @@ -2460,6 +2468,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @method set_from_quick_comment
*/
this.set_from_quick_comment = function(e, quickcomment) {
e.preventDefault();

this.menu.hide();

this.rawtext = quickcomment.rawtext;
Expand All @@ -2477,7 +2487,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @protected
* @method add_to_quicklist
*/
this.add_to_quicklist = function() {
this.add_to_quicklist = function(e) {
e.preventDefault();
this.menu.hide();
this.editor.quicklist.add(this);
};
Expand Down Expand Up @@ -3740,7 +3751,8 @@ EDITOR.prototype = {
* @protected
* @method previous_page
*/
previous_page : function() {
previous_page : function(e) {
e.preventDefault();
this.currentpage--;
if (this.currentpage < 0) {
this.currentpage = 0;
Expand All @@ -3753,7 +3765,8 @@ EDITOR.prototype = {
* @protected
* @method next_page
*/
next_page : function() {
next_page : function(e) {
e.preventDefault();
this.currentpage++;
if (this.currentpage >= this.pages.length) {
this.currentpage = this.pages.length - 1;
Expand Down
4 changes: 3 additions & 1 deletion mod/assign/feedback/editpdf/yui/src/editor/js/annotation.js
Expand Up @@ -233,9 +233,11 @@ Y.extend(ANNOTATION, Y.Base, {
* @method remove
* @param event
*/
remove : function() {
remove : function(e) {
var annotations;

e.preventDefault();

annotations = this.editor.pages[this.editor.currentpage].annotations;
for (i = 0; i < annotations.length; i++) {
if (annotations[i] === this) {
Expand Down
2 changes: 2 additions & 0 deletions mod/assign/feedback/editpdf/yui/src/editor/js/colourpicker.js
Expand Up @@ -58,6 +58,8 @@ Y.extend(COLOURPICKER, M.assignfeedback_editpdf.dropdown, {
COLOURPICKER.superclass.initializer.call(this, config);
},
callback_handler : function(e) {
e.preventDefault();

var callback = this.get('callback'),
callbackcontext = this.get('context'),
bind;
Expand Down
7 changes: 6 additions & 1 deletion mod/assign/feedback/editpdf/yui/src/editor/js/comment.js
Expand Up @@ -330,6 +330,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @method remove_from_quicklist
*/
this.remove_from_quicklist = function(e, quickcomment) {
e.preventDefault();

this.menu.hide();

this.editor.quicklist.remove(quickcomment);
Expand All @@ -343,6 +345,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @method set_from_quick_comment
*/
this.set_from_quick_comment = function(e, quickcomment) {
e.preventDefault();

this.menu.hide();

this.rawtext = quickcomment.rawtext;
Expand All @@ -360,7 +364,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @protected
* @method add_to_quicklist
*/
this.add_to_quicklist = function() {
this.add_to_quicklist = function(e) {
e.preventDefault();
this.menu.hide();
this.editor.quicklist.add(this);
};
Expand Down
Expand Up @@ -39,7 +39,7 @@ Y.extend(COMMENTMENU, M.assignfeedback_editpdf.dropdown, {
commentlinks.append(link);

link = Y.Node.create('<li><a tabindex="-1" href="#">' + M.util.get_string('deletecomment', 'assignfeedback_editpdf') + '</a></li>');
link.on('click', function() { comment.menu.hide(); comment.remove(); }, comment);
link.on('click', function(e) { e.preventDefault(); this.menu.hide(); this.remove(); }, comment);
link.on('key', function() { comment.menu.hide(); comment.remove(); }, 'enter,space', comment);

commentlinks.append(link);
Expand Down
Expand Up @@ -92,6 +92,7 @@ Y.extend(COMMENTSEARCH, M.core.dialogue, {
* @method focus_on_comment
*/
focus_on_comment : function(e) {
e.preventDefault();
var target = e.target.ancestor('li'),
comment = target.getData('comment'),
editor = this.get('editor');
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/feedback/editpdf/yui/src/editor/js/dropdown.js
Expand Up @@ -55,7 +55,7 @@ Y.extend(DROPDOWN, M.core.dialogue, {
}
}, this);

button.on('click', this.show, this);
button.on('click', function(e) {e.preventDefault(); this.show();}, this);
button.on('key', this.show, 'enter,space', this);
},

Expand Down
6 changes: 4 additions & 2 deletions mod/assign/feedback/editpdf/yui/src/editor/js/editor.js
Expand Up @@ -929,7 +929,8 @@ EDITOR.prototype = {
* @protected
* @method previous_page
*/
previous_page : function() {
previous_page : function(e) {
e.preventDefault();
this.currentpage--;
if (this.currentpage < 0) {
this.currentpage = 0;
Expand All @@ -942,7 +943,8 @@ EDITOR.prototype = {
* @protected
* @method next_page
*/
next_page : function() {
next_page : function(e) {
e.preventDefault();
this.currentpage++;
if (this.currentpage >= this.pages.length) {
this.currentpage = this.pages.length - 1;
Expand Down
Expand Up @@ -52,6 +52,7 @@ Y.extend(STAMPPICKER, M.assignfeedback_editpdf.dropdown, {
STAMPPICKER.superclass.initializer.call(this, config);
},
callback_handler : function(e) {
e.preventDefault();
var callback = this.get('callback'),
callbackcontext = this.get('context'),
bind;
Expand Down

0 comments on commit 114913e

Please sign in to comment.