Permalink
Browse files

Merge branch 'MDL-25596' of git://github.com/samhemelryk/moodle

  • Loading branch information...
2 parents c81f657 + 8ad24c1 commit bf97304ac30575638aca608cf763fdb5a3848b63 @skodak skodak committed Dec 27, 2010
View
@@ -268,6 +268,43 @@ M.core_dock.getPanel = function() {
}
return;
};
+ /**
+ * Increases the width of the panel to avoid horizontal scrolling
+ * if possible.
+ */
+ dockpanel.correctWidth = function() {
+ var bd = this.one('.dockeditempanel_bd');
+
+ // Width of content
+ var w = bd.get('clientWidth');
+ // Scrollable width of content
+ var s = bd.get('scrollWidth');
+ // Width of content container with overflow
+ var ow = this.get('offsetWidth');
+ // The new width
+ var nw = w;
+ // The max width (80% of screen)
+ var mw = Math.round(this.get('winWidth') * 0.8);
+
+ // If the scrollable width is more than the visible width
+ if (s > w) {
+ // Content width
+ // + the difference
+ // + any rendering difference (borders, padding)
+ // + 10px to make it look nice.
+ nw = w + (s-w) + ((ow-w)*2) + 10;
+ }
+
+ // Make sure its not more then the maxwidth
+ if (nw > mw) {
+ nw = mw;
+ }
+
+ // Set the new width if its more than the old width.
+ if (nw > ow) {
+ this.setStyle('width', nw+'px');
+ }
+ }
// Put the dockpanel in the body
parent.append(dockpanel);
// Return it
@@ -520,7 +557,7 @@ M.core_dock.init_genericblock = function(Y, id) {
if (!this.initialised) {
this.init(Y);
}
- new this.genericblock(id).init(Y, Y.one('#inst'+id));
+ new this.genericblock(id).initialise_block(Y, Y.one('#inst'+id));
};
/**
* Removes the node at the given index and puts it back into conventional page sturcture
@@ -700,7 +737,7 @@ M.core_dock.genericblock.prototype = {
* @param {YUI.Node} node The node that contains all of the block's content
* @return {M.core_dock.genericblock}
*/
- init : function(Y, node) {
+ initialise_block : function(Y, node) {
M.core_dock.init(Y);
this.Y = Y;
@@ -939,6 +976,7 @@ M.core_dock.item.prototype = {
panel.setHeader(this.titlestring, this.commands);
panel.setBody(Y.Node.create('<div class="'+this.blockclass+' block_docked"></div>').append(this.contents));
panel.show();
+ panel.correctWidth();
this.active = true;
// Add active item class first up
@@ -102,6 +102,13 @@ function instance_can_be_docked() {
function get_required_javascript() {
global $CFG;
user_preference_allow_ajax_update('docked_block_instance_'.$this->instance->id, PARAM_INT);
+ $this->page->requires->js_module('core_dock');
+ $limit = 20;
+ if (!empty($CFG->navcourselimit)) {
+ $limit = $CFG->navcourselimit;
+ }
+ $arguments = array('id'=>$this->instance->id, 'instance'=>$this->instance->id, 'candock'=>$this->instance_can_be_docked(), 'courselimit'=>$limit);
+ $this->page->requires->yui_module(array('core_dock', 'moodle-block_navigation-navigation'), 'M.block_navigation.init_add_tree', array($arguments));
}
/**
@@ -113,7 +120,6 @@ function get_content() {
if ($this->contentgenerated === true) {
return $this->content;
}
- $this->page->requires->yui2_lib('dom');
// JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
// $this->page->requires->js('/lib/javascript-navigation.js');
// Navcount is used to allow us to have multiple trees although I dont' know why
@@ -171,14 +177,7 @@ function get_content() {
}
}
- // Initialise the JS tree object
- $module = array('name'=>'block_navigation', 'fullpath'=>'/blocks/navigation/navigation.js', 'requires'=>array('core_dock', 'io', 'node', 'dom', 'event-custom', 'json-parse'), 'strings'=>array(array('viewallcourses','moodle')));
- $limit = 20;
- if (!empty($CFG->navcourselimit)) {
- $limit = $CFG->navcourselimit;
- }
- $arguments = array($this->instance->id, array('expansions'=>$expandable, 'instance'=>$this->instance->id, 'candock'=>$this->instance_can_be_docked(), 'courselimit'=>$limit));
- $this->page->requires->js_init_call('M.block_navigation.init_add_tree', $arguments, false, $module);
+ $this->page->requires->data_for_js('navtreeexpansions'.$this->instance->id, $expandable);
$options = array();
$options['linkcategories'] = (!empty($this->config->linkcategories) && $this->config->linkcategories == 'yes');
Oops, something went wrong.

0 comments on commit bf97304

Please sign in to comment.