mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-20415 Modified the behaviour of AJAX moving of sections when in "weekly" format, so that dates don't get moved along with the sections. This reflects the final, saved state. Merged from MOODLE_19_STABLE
This commit is contained in:
parent
39e810e9cc
commit
8c3c518f98
@ -159,6 +159,7 @@
|
||||
if (ajaxenabled($CFG->ajaxtestedbrowsers)) { // Browser, user and site-based switches
|
||||
$PAGE->requires->yui_lib('dragdrop');
|
||||
$PAGE->requires->yui_lib('connection');
|
||||
$PAGE->requires->yui_lib('selector');
|
||||
$PAGE->requires->js('lib/ajax/block_classes.js');
|
||||
$PAGE->requires->js('lib/ajax/section_classes.js');
|
||||
|
||||
|
@ -8,6 +8,16 @@
|
||||
//hide content body until done loading (manipulation looks ugly elsewise)
|
||||
//document.getElementById('content').style.display = 'none';
|
||||
|
||||
// If firebug console is undefined, define a fake one here
|
||||
if (window.console) {
|
||||
console.vardump = function(data) {
|
||||
retval = '';
|
||||
for (key in data) {
|
||||
retval += key+' = '+data[key] + "\n";
|
||||
}
|
||||
console.log(retval);
|
||||
};
|
||||
}
|
||||
|
||||
//onload object for handling scripts on page load, this insures they run in my order
|
||||
function onload_class() {
|
||||
@ -45,6 +55,7 @@ function main_class() {
|
||||
|
||||
this.blocks = new Array();
|
||||
this.sections = new Array();
|
||||
this.sectiondates = {};
|
||||
this.leftcolumn = null;
|
||||
this.rightcolumn = null;
|
||||
this.adminBlock = null;
|
||||
@ -108,6 +119,12 @@ main_class.prototype.process_document = function() {
|
||||
while (document.getElementById('section-'+ct) != null) {
|
||||
this.sections[ct] = new section_class('section-'+ct, "sections", null, ct!=0?true:false);
|
||||
this.sections[ct].addToGroup('resources');
|
||||
if (ct > 0) {
|
||||
var sectiontitle = YAHOO.util.Selector.query('#section-'+ct+' h3.weekdates')[0];
|
||||
if (undefined !== sectiontitle) { // Only save date for weekly format
|
||||
this.sectiondates[ct] = sectiontitle.innerHTML;
|
||||
}
|
||||
}
|
||||
ct++;
|
||||
}
|
||||
if (this.debug) {
|
||||
@ -144,7 +161,6 @@ main_class.prototype.get_section_index = function(el) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
main_class.prototype.mk_button = function(tag, imgSrc, text, attributes, imgAttributes) {
|
||||
//Create button and return object.
|
||||
//Set the text: the container TITLE or image ALT attributes can be overridden, eg.
|
||||
|
@ -241,14 +241,14 @@ section_class.prototype.move_to_section = function(target) {
|
||||
if (this.debug) {
|
||||
YAHOO.log("Found target "+main.sections[i].getEl().id);
|
||||
}
|
||||
main.sections[i].swap_dates(main.sections[eval(loopmodifier)]);
|
||||
main.sections[i].swap_with_section(main.sections[eval(loopmodifier)]);
|
||||
main.sections[i].swap_dates(main.sections[eval(loopmodifier)]);
|
||||
found = false;
|
||||
break;
|
||||
} else if (found) {
|
||||
//encounter with nodes inbetween
|
||||
main.sections[i].swap_dates(main.sections[eval(loopmodifier)]);
|
||||
main.sections[i].swap_with_section(main.sections[eval(loopmodifier)]);
|
||||
main.sections[i].swap_dates(main.sections[eval(loopmodifier)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -911,26 +911,12 @@ resource_class.prototype.endDrag = function() {
|
||||
}
|
||||
|
||||
section_class.prototype.swap_dates = function(el){
|
||||
var i=0;
|
||||
while(this.getEl().getElementsByTagName("div")[i]) {
|
||||
if (this.getEl().getElementsByTagName("div")[i].className == "weekdates") {
|
||||
var tempdate = this.getEl().getElementsByTagName("div")[i].innerHTML;
|
||||
var permi = i;
|
||||
}
|
||||
var i=1;
|
||||
var divs = YAHOO.util.Selector.query('div .weekdates');
|
||||
|
||||
for (div in divs) {
|
||||
divs[div].innerHTML = main.sectiondates[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
var j=0;
|
||||
while(el.getEl().getElementsByTagName("div")[j]) {
|
||||
if (el.getEl().getElementsByTagName("div")[j].className == "weekdates") {
|
||||
var permj = j;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
||||
if(tempdate) {
|
||||
this.getEl().getElementsByTagName("div")[permi].innerHTML = el.getEl().getElementsByTagName("div")[permj].innerHTML;
|
||||
el.getEl().getElementsByTagName("div")[permj].innerHTML = tempdate;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user