mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
navigation MDL-21543 Moved block docking icons next to the show-hide block icon
This commit is contained in:
parent
b0fef57b1b
commit
46de77b6b7
@ -335,26 +335,21 @@ M.core_dock = {
|
||||
}
|
||||
}
|
||||
|
||||
var moveto = this.Y.Node.create('<a class="moveto customcommand requiresjs"></a>');
|
||||
moveto.append(this.Y.Node.create('<img src="'+M.util.image_url('t/dock_to_block', 'moodle')+'" alt="'+M.str.block.undockitem+'" title="'+M.str.block.undockitem+'" />'));
|
||||
if (location.href.match(/\?/)) {
|
||||
moveto.set('href', location.href+'&dock='+this.id);
|
||||
} else {
|
||||
moveto.set('href', location.href+'?dock='+this.id);
|
||||
}
|
||||
commands.append(moveto);
|
||||
commands.all('a.moveto').on('movetodock|click', this.move_to_dock, this);
|
||||
var moveto = this.Y.Node.create('<input type="image" class="moveto customcommand requiresjs" src="'+M.util.image_url('t/block_to_dock', 'moodle')+'" alt="'+M.str.block.undockitem+'" title="'+M.str.block.undockitem+'" />');
|
||||
moveto.on('movetodock|click', this.move_to_dock, this, commands);
|
||||
|
||||
node.all('.customcommand').each(function(){
|
||||
this.remove();
|
||||
commands.appendChild(this);
|
||||
});
|
||||
var blockaction = node.one('.block_action');
|
||||
if (blockaction) {
|
||||
blockaction.prepend(moveto);
|
||||
} else {
|
||||
commands.append(moveto);
|
||||
}
|
||||
|
||||
// Move the block straight to the dock if required
|
||||
if (node.hasClass('dock_on_load')) {
|
||||
node.removeClass('dock_on_load')
|
||||
this.skipsetposition = true;
|
||||
this.move_to_dock();
|
||||
this.move_to_dock(null, commands);
|
||||
}
|
||||
},
|
||||
|
||||
@ -363,7 +358,7 @@ M.core_dock = {
|
||||
* dock
|
||||
* @param {event}
|
||||
*/
|
||||
move_to_dock : function(e) {
|
||||
move_to_dock : function(e, commands) {
|
||||
if (e) {
|
||||
e.halt(true);
|
||||
}
|
||||
@ -376,17 +371,6 @@ M.core_dock = {
|
||||
|
||||
this.cachedcontentnode = node;
|
||||
|
||||
node.all('a.moveto').each(function(moveto){
|
||||
this.Y.Event.purgeElement(this.Y.Node.getDOMNode(moveto), false, 'click');
|
||||
if (moveto.hasClass('customcommand')) {
|
||||
moveto.all('img').each(function(movetoimg){
|
||||
movetoimg.setAttribute('src', M.util.image_url('t/dock_to_block', 'moodle'));
|
||||
movetoimg.setAttribute('alt', M.str.block.undockitem);
|
||||
movetoimg.setAttribute('title', M.str.block.undockitem);
|
||||
}, this);
|
||||
}
|
||||
}, this);
|
||||
|
||||
var placeholder = this.Y.Node.create('<div id="content_placeholder_'+this.id+'"></div>');
|
||||
node.replace(this.Y.Node.getDOMNode(placeholder));
|
||||
node = null;
|
||||
@ -396,11 +380,15 @@ M.core_dock = {
|
||||
var blocktitle = this.Y.Node.getDOMNode(this.cachedcontentnode.one('.title h2')).cloneNode(true);
|
||||
blocktitle = this.fix_title_orientation(blocktitle);
|
||||
|
||||
var commands = this.cachedcontentnode.all('.title .commands');
|
||||
var blockcommands = this.Y.Node.create('<div class="commands"></div>');
|
||||
if (commands.size() > 0) {
|
||||
blockcommands = commands.item(0);
|
||||
var blockcommands = this.cachedcontentnode.one('.title .commands');
|
||||
var moveto = this.Y.Node.create('<a class="moveto customcommand requiresjs"></a>');
|
||||
moveto.append(this.Y.Node.create('<img src="'+M.util.image_url('t/dock_to_block', 'moodle')+'" alt="'+M.str.block.undockitem+'" title="'+M.str.block.undockitem+'" />'));
|
||||
if (location.href.match(/\?/)) {
|
||||
moveto.set('href', location.href+'&dock='+this.id);
|
||||
} else {
|
||||
moveto.set('href', location.href+'?dock='+this.id);
|
||||
}
|
||||
blockcommands.append(moveto);
|
||||
|
||||
// Create a new dock item for the block
|
||||
var dockitem = new M.core_dock.item(this.Y, this.id, blocktitle, blockcontent, blockcommands);
|
||||
@ -410,12 +398,12 @@ M.core_dock = {
|
||||
// Wire the draw events to register remove events
|
||||
dockitem.on('dockeditem:drawcomplete', function(e){
|
||||
// check the contents block [editing=off]
|
||||
this.contents.all('a.moveto').on('returntoblock|click', function(e){
|
||||
this.contents.all('.moveto').on('returntoblock|click', function(e){
|
||||
e.halt();
|
||||
M.core_dock.remove(this.id)
|
||||
}, this);
|
||||
// check the commands block [editing=on]
|
||||
this.commands.all('a.moveto').on('returntoblock|click', function(e){
|
||||
this.commands.all('.moveto').on('returntoblock|click', function(e){
|
||||
e.halt();
|
||||
M.core_dock.remove(this.id)
|
||||
}, this);
|
||||
@ -488,29 +476,11 @@ M.core_dock = {
|
||||
|
||||
this.resize_block_space(this.cachedcontentnode);
|
||||
|
||||
this.cachedcontentnode.all('a.moveto').each(function(moveto){
|
||||
this.Y.Event.purgeElement(this.Y.Node.getDOMNode(moveto), false, 'click');
|
||||
moveto.on('movetodock|click', this.move_to_dock, this);
|
||||
if (moveto.hasClass('customcommand')) {
|
||||
moveto.all('img').each(function(movetoimg){
|
||||
movetoimg.setAttribute('src', M.util.image_url('t/block_to_dock', 'moodle'));
|
||||
movetoimg.setAttribute('alt', M.str.block.addtodock);
|
||||
movetoimg.setAttribute('title', M.str.block.addtodock);
|
||||
}, this);
|
||||
}
|
||||
}, this);
|
||||
|
||||
var commands = this.cachedcontentnode.all('.commands');
|
||||
commands.each(function (command){
|
||||
command.all('.hidepanelicon').remove();
|
||||
});
|
||||
var blocktitle = this.cachedcontentnode.all('.title');
|
||||
|
||||
if (commands.size() === 1 && blocktitle.size() === 1) {
|
||||
commands.item(0).remove();
|
||||
blocktitle.item(0).append(commands.item(0));
|
||||
}
|
||||
|
||||
var commands = this.cachedcontentnode.one('.commands');
|
||||
commands.all('.hidepanelicon').remove();
|
||||
commands.all('.moveto').remove();
|
||||
commands.remove();
|
||||
this.cachedcontentnode.one('.title').append(commands);
|
||||
this.cachedcontentnode = null;
|
||||
M.util.set_user_preference('docked_block_instance_'+this.id, 0);
|
||||
return true;
|
||||
@ -564,7 +534,11 @@ M.core_dock = {
|
||||
}
|
||||
dockitem.append(dockitemtitle);
|
||||
if (this.commands.hasChildNodes) {
|
||||
this.contents.appendChild(this.commands);
|
||||
if (this.contents.ancestor().one('.footer')) {
|
||||
this.contents.ancestor().one('.footer').appendChild(this.commands);
|
||||
} else {
|
||||
this.contents.appendChild(this.commands);
|
||||
}
|
||||
}
|
||||
M.core_dock.append(dockitem);
|
||||
|
||||
|
@ -65,7 +65,6 @@ M.block_navigation = M.block_navigation || {
|
||||
* @base M.core_dock.abstractblock
|
||||
* @param {YUI} Y A yui instance to use with the navigation
|
||||
* @param {string} id The name of the tree
|
||||
* @param {int} key The internal id within the tree store
|
||||
* @param {object} properties Object containing tree properties
|
||||
*/
|
||||
M.block_navigation.classes.tree = function(Y, id, properties) {
|
||||
|
@ -567,7 +567,7 @@ class block_base {
|
||||
|
||||
function get_required_javascript() {
|
||||
$this->_initialise_dock();
|
||||
if ($this->instance_can_be_docked()) {
|
||||
if ($this->instance_can_be_docked() && !$this->hide_header()) {
|
||||
$this->page->requires->js_init_call('M.core_dock.init_genericblock', array($this->instance->id));
|
||||
user_preference_allow_ajax_update('docked_block_instance_'.$this->instance->id, PARAM_INT);
|
||||
}
|
||||
|
@ -1298,9 +1298,12 @@ function block_hider(id, userpref, visibletooltip, hiddentooltip, visibleicon, h
|
||||
// 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);
|
||||
|
||||
var blockactions = YAHOO.util.Dom.getElementsByClassName('block_action', 'div', title_div);
|
||||
if (blockactions && blockactions[0]) {
|
||||
blockactions[0].insertBefore(this.icon, blockactions[0].firstChild);
|
||||
}
|
||||
|
||||
// Hook up the event handler.
|
||||
YAHOO.util.Event.addListener(this.icon, 'click', this.handle_click, null, this);
|
||||
|
@ -746,10 +746,13 @@ class core_renderer extends renderer_base {
|
||||
}
|
||||
|
||||
if ($title || $controlshtml) {
|
||||
$output .= html_writer::tag('div', html_writer::tag('div', $title . $controlshtml, array('class' => 'title')), array('class' => 'header'));
|
||||
$output .= html_writer::tag('div', html_writer::tag('div', html_writer::tag('div', '', array('class'=>'block_action')). $title . $controlshtml, array('class' => 'title')), array('class' => 'header'));
|
||||
}
|
||||
|
||||
$output .= html_writer::start_tag('div', array('class' => 'content'));
|
||||
if (!$title && !$controlshtml) {
|
||||
$output .= html_writer::tag('div', '', array('class'=>'block_action notitle'));
|
||||
}
|
||||
$output .= $bc->content;
|
||||
|
||||
if ($bc->footer) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sideblock .header .hide-show-image {
|
||||
.sideblock .header .block_action {
|
||||
float:right;
|
||||
}
|
||||
|
||||
|
@ -1573,17 +1573,23 @@ a.skip:focus, a.skip:active {
|
||||
padding:0;
|
||||
}
|
||||
|
||||
.sideblock .header .hide-show-image {
|
||||
.sideblock .header .block_action,
|
||||
.sideblock .content .block_action.notitle {
|
||||
float:right;
|
||||
height:11px;
|
||||
width:11px;
|
||||
margin-top:0.25em;
|
||||
}
|
||||
|
||||
.sideblock .header .block_action input,
|
||||
.sideblock .content .block_action.notitle input {
|
||||
margin-right:2px;
|
||||
height:11px;
|
||||
width:11px;
|
||||
}
|
||||
|
||||
.sideblock .header .commands {
|
||||
margin-top: 0.3em;
|
||||
clear: both;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.sideblock .header .commands a {
|
||||
@ -1800,10 +1806,6 @@ a.skip:focus, a.skip:active {
|
||||
/**
|
||||
* Navigation and settings block
|
||||
**/
|
||||
.customcommand img {
|
||||
margin-left:2px;
|
||||
margin-right:2px;
|
||||
}
|
||||
.sideblock .block_tree_box {
|
||||
margin:2px;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user