themes & blocks - MDL-19077 & MDL-19010 blocks are now printed by the theme
The code to print blocks in now in theme layout.php files. (Or in moodle_core_renderer::handle_legacy_theme) Code for printing blocks everywhere else has been stripped out. (Total diffstat 1225 insertions, 2019 deletions) The way the HTML for a block instance is generated has been cleaned up a lot. Now, the block_instance generates a block_contents object which gives a structured representation of the block, and then $OUTPUT->block builds all the HTML from that. How theme config.php files specify the layout template and block regions by page general type has been changed to be even more flexible. Further refinement for how the theme and block code gets initialised. Ability for scrits to add 'pretend blocks' to the page. That is, things that look like blocks, but are not normal block_instances. (Like the add a new block UI.) Things that are still broken: * some pages in lesson, quiz and resource. I'm working on it. * lots of developer debug notices pointing out things that need to be updated.
This commit is contained in:
+62
-51
@@ -617,55 +617,6 @@ date_selector_calendar.prototype.release_calendar = function() {
|
||||
date_selector_calendar.calendar.selectEvent.unsubscribe(this.set_selects_from_date, this);
|
||||
}
|
||||
|
||||
/**
|
||||
elementToggleHide (element, elementFinder)
|
||||
|
||||
If elementFinder is not provided, toggles the "hidden" class for the specified element.
|
||||
If elementFinder is provided, then the "hidden" class will be toggled for the object
|
||||
returned by the function call elementFinder(element).
|
||||
|
||||
If persistent == true, also sets a cookie for this.
|
||||
*/
|
||||
function elementToggleHide(el, persistent, elementFinder, strShow, strHide) {
|
||||
if(!elementFinder) {
|
||||
var obj = el; //el:container
|
||||
el = document.getElementById('togglehide_'+obj.id);
|
||||
}
|
||||
else {
|
||||
var obj = elementFinder(el); //el:button.
|
||||
}
|
||||
if(obj.className.indexOf('hidden') == -1) {
|
||||
obj.className += ' hidden';
|
||||
if (el.src) {
|
||||
el.src = el.src.replace('switch_minus', 'switch_plus');
|
||||
el.alt = strShow;
|
||||
el.title = strShow;
|
||||
}
|
||||
var shown = 0;
|
||||
}
|
||||
else {
|
||||
obj.className = obj.className.replace(new RegExp(' ?hidden'), '');
|
||||
if (el.src) {
|
||||
el.src = el.src.replace('switch_plus', 'switch_minus');
|
||||
el.alt = strHide;
|
||||
el.title = strHide;
|
||||
}
|
||||
var shown = 1;
|
||||
}
|
||||
|
||||
if(persistent == true) {
|
||||
new cookie('hide:' + obj.id, 1, (shown ? -1 : 356), '/').set();
|
||||
}
|
||||
}
|
||||
|
||||
function elementCookieHide(id, strShow, strHide) {
|
||||
var obj = document.getElementById(id);
|
||||
var cook = new cookie('hide:' + id).read();
|
||||
if(cook != null) {
|
||||
elementToggleHide(obj, false, null, strShow, strHide);
|
||||
}
|
||||
}
|
||||
|
||||
function filterByParent(elCollection, parentFinder) {
|
||||
var filteredCollection = [];
|
||||
for (var i = 0; i < elCollection.length; ++i) {
|
||||
@@ -921,8 +872,7 @@ function collapsible_region(id, userpref, strtooltip, collapsedicon, expandedico
|
||||
a.appendChild(this.icon);
|
||||
|
||||
// Hook up the event handler.
|
||||
var self = this;
|
||||
YAHOO.util.Event.addListener(a, 'click', function(e) {self.handle_click(e);});
|
||||
YAHOO.util.Event.addListener(a, 'click', this.handle_click, null, this);
|
||||
|
||||
// Handler for the animation finishing.
|
||||
this.animation.onComplete.subscribe(function() {self.handle_animation_complete();});
|
||||
@@ -1007,6 +957,67 @@ collapsible_region.prototype.handle_animation_complete = function() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Oject to handle expanding and collapsing blocks when an icon is clicked on.
|
||||
* @constructor
|
||||
* @param String id the HTML id for the div.
|
||||
* @param String userpref the user preference that records the state of this block.
|
||||
* @param String visibletooltip tool tip/alt to show when the block is visible.
|
||||
* @param String hiddentooltip tool tip/alt to show when the block is hidden.
|
||||
* @param String visibleicon URL of the icon to show when the block is visible.
|
||||
* @param String hiddenicon URL of the icon to show when the block is hidden.
|
||||
*/
|
||||
function block_hider(id, userpref, visibletooltip, hiddentooltip, visibleicon, hiddenicon) {
|
||||
// Find the elemen that is the block.
|
||||
this.block = document.getElementById(id);
|
||||
var title_div = YAHOO.util.Dom.getElementsByClassName('title', 'div', this.block);
|
||||
if (!title_div || !title_div[0]) {
|
||||
return this;
|
||||
}
|
||||
title_div = title_div[0];
|
||||
this.ishidden = YAHOO.util.Dom.hasClass(this.block, 'hidden');
|
||||
|
||||
// Record the pref name
|
||||
this.userpref = userpref;
|
||||
this.visibletooltip = visibletooltip;
|
||||
this.hiddentooltip = hiddentooltip;
|
||||
this.visibleicon = visibleicon;
|
||||
this.hiddenicon = hiddenicon;
|
||||
|
||||
// Add the icon.
|
||||
this.icon = document.createElement('input');
|
||||
this.icon.type = 'image';
|
||||
this.icon.className = 'hide-show-image';
|
||||
this.update_state();
|
||||
title_div.insertBefore(this.icon, title_div.firstChild);
|
||||
|
||||
// Hook up the event handler.
|
||||
YAHOO.util.Event.addListener(this.icon, 'click', this.handle_click, null, this);
|
||||
}
|
||||
|
||||
/** Handle click on a block show/hide icon. */
|
||||
block_hider.prototype.handle_click = function(e) {
|
||||
YAHOO.util.Event.stopEvent(e);
|
||||
this.ishidden = !this.ishidden;
|
||||
this.update_state();
|
||||
set_user_preference(this.userpref, this.ishidden);
|
||||
}
|
||||
|
||||
/** Set the state of the block show/hide icon to this.ishidden. */
|
||||
block_hider.prototype.update_state = function () {
|
||||
if (this.ishidden) {
|
||||
YAHOO.util.Dom.addClass(this.block, 'hidden');
|
||||
this.icon.alt = this.hiddentooltip;
|
||||
this.icon.title = this.hiddentooltip;
|
||||
this.icon.src = this.hiddenicon;
|
||||
} else {
|
||||
YAHOO.util.Dom.removeClass(this.block, 'hidden');
|
||||
this.icon.alt = this.visibletooltip;
|
||||
this.icon.title = this.visibletooltip;
|
||||
this.icon.src = this.visibleicon;
|
||||
}
|
||||
}
|
||||
|
||||
/** Close the current browser window. */
|
||||
function close_window() {
|
||||
window.close();
|
||||
|
||||
Reference in New Issue
Block a user