MDL-45314 core_grade: keep the two grader report scrollbars the same when the table changes width

This commit is contained in:
Andrew Davis 2014-04-29 11:43:13 +08:00
parent f500ff4e52
commit 85b609c938
5 changed files with 25 additions and 7 deletions

View File

@ -378,6 +378,12 @@ M.gradereport_grader.classes.ajax.prototype.make_editable = function(e) {
break;
}
this.current.replace().attach_key_events();
// Making a field editable changes the grade table width.
// Update the top scroll bar to reflect the new table width.
Y.use('moodle-gradereport_grader-scrollview', function() {
M.gradereport_grader.scrollview.resize();
});
};
/**
* Callback function for the user pressing the enter key on an editable field

View File

@ -62,8 +62,7 @@ M.gradereport_grader.scrollview = {
var _this = this;
Y.on('domready', function () {
var width = Y.one(_this.SELECTORS.GRADETABLE).get('offsetWidth');
Y.one('.topscrollcontent').setStyle('width', width + 'px');
M.gradereport_grader.scrollview.resize();
});
Y.one(src).on('scroll', function() {
@ -74,6 +73,11 @@ M.gradereport_grader.scrollview = {
Y.one(src).set('scrollLeft', node.get('scrollLeft'));
});
},
resize: function() {
var width = Y.one(M.gradereport_grader.scrollview.SELECTORS.GRADETABLE).get('offsetWidth');
Y.one('.topscrollcontent').setStyle('width', width + 'px');
}
};

View File

@ -1 +1 @@
YUI.add("moodle-gradereport_grader-scrollview",function(e,t){M.gradereport_grader=M.gradereport_grader||{},M.gradereport_grader.scrollview={SELECTORS:{CONTAINER:".gradeparent",STATIC:".gradeparent .right_scroller",GRADETABLE:"#user-grades"},container:null,init:function(){this.container=e.one(this.SELECTORS.CONTAINER);if(!this.container)return;var t=e.Node.create('<div class="right_scroller topscroll"><div class="topscrollcontent"></div></div>'),n=this.SELECTORS.CONTAINER;e.one(this.SELECTORS.STATIC)&&(n=this.SELECTORS.STATIC);var r=e.one(n).insert(t,"before");e.one(this.SELECTORS.STATIC)||(r=e.one(".topscroll"));var i=this;e.on("domready",function(){var t=e.one(i.SELECTORS.GRADETABLE).get("offsetWidth");e.one(".topscrollcontent").setStyle("width",t+"px")}),e.one(n).on("scroll",function(){r.set("scrollLeft",e.one(n).get("scrollLeft"))}),r.on("scroll",function(){e.one(n).set("scrollLeft",r.get("scrollLeft"))})}}},"@VERSION@",{requires:["base","node"]});
YUI.add("moodle-gradereport_grader-scrollview",function(e,t){M.gradereport_grader=M.gradereport_grader||{},M.gradereport_grader.scrollview={SELECTORS:{CONTAINER:".gradeparent",STATIC:".gradeparent .right_scroller",GRADETABLE:"#user-grades"},container:null,init:function(){this.container=e.one(this.SELECTORS.CONTAINER);if(!this.container)return;var t=e.Node.create('<div class="right_scroller topscroll"><div class="topscrollcontent"></div></div>'),n=this.SELECTORS.CONTAINER;e.one(this.SELECTORS.STATIC)&&(n=this.SELECTORS.STATIC);var r=e.one(n).insert(t,"before");e.one(this.SELECTORS.STATIC)||(r=e.one(".topscroll"));var i=this;e.on("domready",function(){M.gradereport_grader.scrollview.resize()}),e.one(n).on("scroll",function(){r.set("scrollLeft",e.one(n).get("scrollLeft"))}),r.on("scroll",function(){e.one(n).set("scrollLeft",r.get("scrollLeft"))})},resize:function(){var t=e.one(M.gradereport_grader.scrollview.SELECTORS.GRADETABLE).get("offsetWidth");e.one(".topscrollcontent").setStyle("width",t+"px")}}},"@VERSION@",{requires:["base","node"]});

View File

@ -61,8 +61,7 @@ M.gradereport_grader.scrollview = {
var _this = this;
Y.on('domready', function () {
var width = Y.one(_this.SELECTORS.GRADETABLE).get('offsetWidth');
Y.one('.topscrollcontent').setStyle('width', width + 'px');
M.gradereport_grader.scrollview.resize();
});
Y.one(src).on('scroll', function() {
@ -73,6 +72,11 @@ M.gradereport_grader.scrollview = {
Y.one(src).set('scrollLeft', node.get('scrollLeft'));
});
},
resize: function() {
var width = Y.one(M.gradereport_grader.scrollview.SELECTORS.GRADETABLE).get('offsetWidth');
Y.one('.topscrollcontent').setStyle('width', width + 'px');
}
};

View File

@ -60,8 +60,7 @@ M.gradereport_grader.scrollview = {
var _this = this;
Y.on('domready', function () {
var width = Y.one(_this.SELECTORS.GRADETABLE).get('offsetWidth');
Y.one('.topscrollcontent').setStyle('width', width + 'px');
M.gradereport_grader.scrollview.resize();
});
Y.one(src).on('scroll', function() {
@ -72,5 +71,10 @@ M.gradereport_grader.scrollview = {
Y.one(src).set('scrollLeft', node.get('scrollLeft'));
});
},
resize: function() {
var width = Y.one(M.gradereport_grader.scrollview.SELECTORS.GRADETABLE).get('offsetWidth');
Y.one('.topscrollcontent').setStyle('width', width + 'px');
}
};