Skip to content

Commit

Permalink
MDL-38923 theme bootstrapbase: theme clean: enable docking
Browse files Browse the repository at this point in the history
  • Loading branch information
bmbrands authored and Sam Hemelryk committed May 18, 2014
1 parent ba05f57 commit 056b54f
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 4 deletions.
4 changes: 2 additions & 2 deletions theme/bootstrapbase/config.php
Expand Up @@ -35,7 +35,7 @@
$THEME->parents = array();
$THEME->sheets = array('moodle');
$THEME->supportscssoptimisation = false;

$THEME->enable_dock = false;
$THEME->editor_sheets = array('editor');

$THEME->rendererfactory = 'theme_overridden_renderer_factory';
Expand Down Expand Up @@ -154,7 +154,7 @@
$THEME->javascripts = array(
);
$THEME->javascripts_footer = array(
'moodlebootstrap',
'moodlebootstrap', 'dockmod'
);

if (core_useragent::is_ie() && !core_useragent::check_ie_version('9.0')) {
Expand Down
85 changes: 85 additions & 0 deletions theme/bootstrapbase/javascript/dockmod.js
@@ -0,0 +1,85 @@
function customise_dock_for_theme() {
var dock = M.core_dock;
dock.on('dock:itemschanged', theme_dockmod_handle_spans);
dock.on('dock:panelgenerated', theme_dockmod_blockstyle);
}

//Add the "block" class to docked blocks. This prevents having to restyle
//all docked blocks and simply use standard block styling
function theme_dockmod_blockstyle() {
Y.all('.dockeditempanel_content').each(function(dockblock){
dockblock.addClass('block');
});
}

//On docking and undocking the bootstrap spans have to change to
//dock properly
function theme_dockmod_handle_spans() {

var prepopulatedblockregions = 0;
var postpopulatedblockregions = 0;

var blockspre = 0;
var blockspost = 0;

var maincontent = Y.one('#region-main');
var regionpre = Y.one('#block-region-side-pre');
var regionpost = Y.one('#block-region-side-post');
var ltr = Y.one('body.dir-ltr');
var mainwrapper = Y.one('#region-bs-main-and-pre');
if (!ltr) {
var mainwrapper = Y.one('#region-bs-main-and-post');
}

var body = Y.one('body');

if (Y.all('.block.dock_on_load').size()>0) {
// Do not resize during initial load
return;
}

if (body.hasClass('blocks-moving')) {
// open up blocks during blocks positioning
return;
}


if (body.hasClass('two-column')) {

var prehasblocks = (regionpre.all('.block').size() > 0);
if (prehasblocks) {
regionpre.addClass('span3');
maincontent.removeClass('span12');
maincontent.addClass('span9');
} else {
regionpre.removeClass('span3');
maincontent.removeClass('span9');
maincontent.addClass('span12');
}
} else {

var prehasblocks = (regionpre.all('.block').size() > 0);
if (prehasblocks) {
regionpre.addClass('span4');
maincontent.removeClass('span12');
maincontent.addClass('span8');
} else {
regionpre.removeClass('span4');
maincontent.removeClass('span8');
maincontent.addClass('span12');
}

var posthasblocks = (regionpost.all('.block').size() > 0);
if (posthasblocks) {
regionpost.addClass('span3');
mainwrapper.removeClass('span12');
mainwrapper.addClass('span9');
} else {
mainwrapper.removeClass('span9');
mainwrapper.addClass('span12');
regionpost.removeClass('span3');
}
}
return;

}
1 change: 1 addition & 0 deletions theme/bootstrapbase/less/moodle.less
Expand Up @@ -56,6 +56,7 @@ body {
@import "moodle/tables";
@import "moodle/buttons";
@import "moodle/grade";
@import "moodle/dock";

// Anything below this line is considered expendable,
// so it doesn't matter if it doesn't show up in ie < 9
Expand Down
157 changes: 157 additions & 0 deletions theme/bootstrapbase/less/moodle/dock.less
@@ -0,0 +1,157 @@
.dockbutton {
.btn;
display: list-item;
padding: 0;
}

body.has_dock {
margin-left: 20px;
div#dock {
display: inline;
}
}

#dock {
width: 36px;
position: fixed;
top: 68px;
left: 0px;
height: 90%;
background-color: transparent;
border-right: 0 none;
.nothingdocked {
visibility: hidden;
display: none;
}
.dockeditem .firstdockitem {
margin-top: 1em;
}
.dockedtitle {
.dockbutton;
cursor: pointer;
margin: 2px;
h2 {
font-family: @sansFontFamily;
font-size: 1em;
line-height: 100%;
text-align: center;
font-weight: bold;
}

.filterrotate {
margin-left: 8px;
}
}
.dockeditempanel_hd h2 {
.nav-header;
font-size: 1.1em;
}
.controls {
position: absolute;
bottom: 1em;
text-align: center;
width: 100%;
img {
cursor: pointer;
}
}
}

#dockeditempanel {
min-width: 200px;
position: relative;
z-index: 12000;
left: 100%;
padding-left: 5px;
.dockeditempanel_content {
z-index: 12050;
background-color: @wellBackground;
width: 220px;
box-shadow: 2px 4px 4px 2px #CCCCCC;
}
.dockeditempanel_bd {
overflow: auto;
width: auto;
.block_navigation .block_tree li {
overflow: visible;
}
}
.dockeditempanel_hd {
h2 {
padding: 10px;
margin: 0;
border-bottom: 1px solid @white;
}
.commands {
width: 60px;
float: right;
position: absolute;
right: 0px;
display: block;
text-align: right;
top: 6px;
}
.commands > a,
.commands > span {
margin-left: 3px;
cursor: pointer;
}
a.editing_move,
a.editing_edit,
a.editing_roles,
a.editing_delete,
a.editing_hide {
display: none;
}
.commands img,
.commands input {
vertical-align: middle;
margin-right: 1px;
}
.commands .hidepanemicon img {
cursor: pointer;
}
}

}

#dockeditempanel.dockitempanel_hidden {
display: none;
}

.dir-rtl {
#dockeditempanel {
right: 100%;
.dockeditempanel_hd .commands {
text-align: left;
}
}
#dock {
left: auto;
right: 0%;
.dockedtitle {
border-bottom: 1px solid #DDD;
border-top: 1px solid #EEE;
cursor: pointer;
}
}
.dockeditempanel_hd {
h2 {
padding: 10px;
margin: 0;
border-bottom: 1px solid @white;
}
.commands {
float: left;
right: auto;
left: 0px;
text-align: left;
top: 6px;
}
}
}

body.dir-rtl.has_dock {
margin-left: 0px;
margin-right: 20px;
}
2 changes: 1 addition & 1 deletion theme/bootstrapbase/style/moodle.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion theme/clean/config.php
Expand Up @@ -41,7 +41,7 @@
$THEME->sheets = array('custom');
$THEME->supportscssoptimisation = false;
$THEME->yuicssmodules = array();

$THEME->enable_dock = true;
$THEME->editor_sheets = array();

$THEME->rendererfactory = 'theme_overridden_renderer_factory';
Expand Down

0 comments on commit 056b54f

Please sign in to comment.