diff --git a/blocks/dock.js b/blocks/dock.js index 503a646f12b..609277800b0 100644 --- a/blocks/dock.js +++ b/blocks/dock.js @@ -30,6 +30,7 @@ M.core_dock = { buffer:10, // Buffer used when containing a panel position:'left', // position of the dock orientation:'vertical', // vertical || horizontal determines if we change the title + titlerotation:'counterclockwise', /** * Display parameters for the dock * @namespace @@ -378,7 +379,7 @@ M.core_dock = { this.cachedcontentnode = node; - var placeholder = this.Y.Node.create('
'); + var placeholder = this.Y.Node.create('
'); node.replace(this.Y.Node.getDOMNode(placeholder)); node = null; @@ -442,8 +443,57 @@ M.core_dock = { * @param {YUI.Node} node */ fix_title_orientation : function(node) { - node.innerHTML = node.innerHTML.replace(/(.)/g, "$1
"); - return node; + var title = node.firstChild.nodeValue; + + var clockwise = false; + if (M.core_dock.cfg.titlerotation == 'counterclockwise') { + clockwise = false; + } else if (M.core_dock.cfg.titlerotation == 'clockwise') { + clockwise = true; + } else { + clockwise = (M.core_dock.cfg.titleorientation)(M.str.langconfig.thisdirectionvertical=='ttb'); + } + + if (YAHOO.env.ua.ie > 0) { + if (YAHOO.env.ua.ie > 7) { + // IE8 can flip the text via CSS + node.setAttribute('style', 'writing-mode: tb-rl; filter: flipV flipH;'); + } else { + // IE < 7 can't do anything cool, just settle to stacked letters + title = title.split('').join('
'); + node.innerHTML = title; + } + return node; + } + + // Cool, we can use SVG! + var test = M.core_dock.Y.Node.create('
'+title+'
'); + M.core_dock.Y.one(document.body).append(test); + var height = test.one('span').get('offsetWidth'); + var width = test.one('span').get('offsetHeight')*2; + var qwidth = width/4; + test.remove(); + + var txt = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + txt.setAttribute('font-size', '10'); + if (clockwise) { + txt.setAttribute('transform','rotate(90 '+(qwidth/2)+' '+qwidth+')'); + } else { + txt.setAttribute('y', height); + txt.setAttribute('transform','rotate(270 '+qwidth+' '+(height-qwidth)+')'); + } + txt.appendChild(document.createTextNode(node.firstChild.nodeValue)); + + var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + svg.setAttribute('version', '1.1'); + svg.setAttribute('height', height); + svg.setAttribute('width', width); + svg.appendChild(txt); + + var div = document.createElement(node.nodeName); + div.appendChild(svg); + + return div; }, /** * Resizes the space that contained blocks if there were no blocks left in @@ -451,22 +501,39 @@ M.core_dock = { * @param {Y.Node} node */ resize_block_space : function(node) { - node = node.ancestor('.block-region'); - if (node) { - var width = node.getStyle('width'); - if (node.all('.block').size() === 0 && this.blockspacewidth === null) { - // If the node has no children then we can shrink it - this.blockspacewidth = width; - node.setStyle('width', '0px'); - } else if (this.blockspacewidth !== null) { - // Otherwise if it contains children and we have saved a width - // we can reapply the width - node.setStyle('width', this.blockspacewidth); - this.blockspacewidth = null; + var blockregions = []; + var populatedblockregions = 0; + M.core_dock.Y.all('.block-region').each(function(region){ + var hasblocks = (region.all('.block').size() > 0); + if (hasblocks) { + populatedblockregions++; + } + blockregions[region.get('id')] = {hasblocks: hasblocks, bodyclass: region.get('id').replace(/^region\-/, 'side-')+'-only'}; + }); + var bodynode = M.core_dock.Y.one(document.body); + var noblocksbodyclass = 'content-only'; + var i = null; + if (populatedblockregions==0) { + bodynode.addClass(noblocksbodyclass); + for (i in blockregions) { + bodynode.removeClass(blockregions[i].bodyclass); + } + } else if (populatedblockregions==1) { + bodynode.removeClass(noblocksbodyclass); + for (i in blockregions) { + if (!blockregions[i].hasblocks) { + bodynode.removeClass(blockregions[i].bodyclass); + } else { + bodynode.addClass(blockregions[i].bodyclass); + } + } + } else { + bodynode.removeClass(noblocksbodyclass); + for (i in blockregions) { + bodynode.removeClass(blockregions[i].bodyclass); } - return width; } - return null; + return '200px'; }, /** * This function removes a block from the dock and puts it back into the page diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index c1b268886f4..e52905738a2 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -381,7 +381,7 @@ class page_requirements_manager { $module = array('name' => 'core_dock', 'fullpath' => '/blocks/dock.js', 'requires' => array('base', 'cookie', 'dom', 'io', 'node', 'event-custom', 'event-mouseenter', 'yui2-container'), - 'strings' => array(array('addtodock', 'block'),array('undockitem', 'block'),array('undockall', 'block'))); + 'strings' => array(array('addtodock', 'block'),array('undockitem', 'block'),array('undockall', 'block'),array('thisdirectionvertical', 'langconfig'))); break; case 'core_calendar': $module = array('name' => 'core_calendar', diff --git a/theme/base/layout/frontpage.php b/theme/base/layout/frontpage.php index 67b4e583927..32ce42e499e 100644 --- a/theme/base/layout/frontpage.php +++ b/theme/base/layout/frontpage.php @@ -57,7 +57,7 @@ echo $OUTPUT->doctype() ?> -
+
blocks_for_region('side-pre') ?>
@@ -65,7 +65,7 @@ echo $OUTPUT->doctype() ?> -
+
blocks_for_region('side-post') ?>
diff --git a/theme/base/layout/general.php b/theme/base/layout/general.php index 803570a2284..7dca3db8edb 100644 --- a/theme/base/layout/general.php +++ b/theme/base/layout/general.php @@ -68,7 +68,7 @@ echo $OUTPUT->doctype() ?>
-
+
blocks_for_region('side-pre') ?>
@@ -76,7 +76,7 @@ echo $OUTPUT->doctype() ?> -
+
blocks_for_region('side-post') ?>
diff --git a/theme/standard/javascript/navigation.js b/theme/standard/javascript/navigation.js index e2d4cc34174..035a7c3024d 100644 --- a/theme/standard/javascript/navigation.js +++ b/theme/standard/javascript/navigation.js @@ -5,80 +5,5 @@ function customise_dock_for_theme() { } // Throw a lightbox for the navigation boxes M.core_dock.cfg.panel.modal = true; - /** - * This function converts the title of each docked block to make it vertical. - * - * In the case of browsers that support svg (scalable vector graphics) an SVG is - * generated to rotate the text. In the case of IE we have to settle for making - * it letter over letter. - * - * @param {Y.Node} node - */ - M.core_dock.genericblock.prototype.fix_title_orientation = function(node) { - if (YAHOO.env.ua.ie > 0) { - if (YAHOO.env.ua.ie > 7) { - // IE8 can flip the text via CSS - node.setAttribute('style', 'writing-mode: tb-rl; filter: flipV flipH;'); - } else { - // IE < 7 can't do anything cool, just settle to stacked letters - node.innerHTML = node.innerHTML.replace(/(.)/g, "$1
"); - } - return node; - } - // Cool, we can use SVG! - var test = M.core_dock.Y.Node.create('
'+node.firstChild.nodeValue+'
'); - M.core_dock.Y.one(document.body).append(test); - var height = test.one('span').get('offsetWidth'); - test.remove(); - - var txt = document.createElementNS('http://www.w3.org/2000/svg', 'text'); - txt.setAttribute('x', '0'); - txt.setAttribute('y', '0'); - txt.setAttribute('transform','rotate(90, 5, 5)'); - txt.appendChild(document.createTextNode(node.firstChild.nodeValue)); - - var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - svg.setAttribute('version', '1.1'); - svg.setAttribute('height', height); - svg.setAttribute('width', 30); - svg.appendChild(txt); - - var div = document.createElement(node.nodeName); - div.appendChild(svg); - - return div; - } - /** - * This function makes sure that if all blocks from one side or the other are docked - * the gap that is left behind if closed up. This is done of course by using classes. - */ - M.core_dock.genericblock.prototype.resize_block_space = function() { - var blockregions = { - pre: { - hasblocks : (M.core_dock.Y.one('#region-pre') && M.core_dock.Y.one('#region-pre').all('.block').size() > 0), - c : 'side-pre-only' - }, - post: { - hasblocks : (M.core_dock.Y.one('#region-post') && M.core_dock.Y.one('#region-post').all('.block').size() > 0), - c : 'side-post-only' - }, - noblocksc:'content-only' - } - - if (blockregions.pre.hasblocks && blockregions.post.hasblocks) { - // No classes required both regions have blocks - M.core_dock.Y.one(document.body).removeClass(blockregions.pre.c).removeClass(blockregions.post.c).removeClass(blockregions.noblocksc); - } else if (blockregions.pre.hasblocks) { - // side-pre-only required: remove any other classes - M.core_dock.Y.one(document.body).addClass(blockregions.pre.c).removeClass(blockregions.post.c).removeClass(blockregions.noblocksc); - } else if (blockregions.post.hasblocks) { - // side-post-only required: remove any other classes - M.core_dock.Y.one(document.body).removeClass(blockregions.pre.c).addClass(blockregions.post.c).removeClass(blockregions.noblocksc); - } else { - // All blocks have been docked: add noblocks remove side-xxx-only's if set - M.core_dock.Y.one(document.body).removeClass(blockregions.pre.c).removeClass(blockregions.post.c).addClass(blockregions.noblocksc); - } - return '200px'; - } return true; } \ No newline at end of file