Merge branch 'MDL-54722-master' of git://github.com/cameron1729/moodle

This commit is contained in:
Andrew Nicols 2016-06-01 12:24:14 +08:00
commit 69dcebb04d
15 changed files with 84 additions and 26 deletions

View File

@ -1 +1 @@
define(["jquery","core/tree"],function(a,b){return{init:function(){new b(".block_navigation .block_tree")}}});
define(["jquery","core/tree"],function(a,b){return{init:function(a){var c=new b(".block_navigation .block_tree");c.finishExpandingGroup=function(c){b.prototype.finishExpandingGroup.call(this,c),Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED,{instanceid:a})},c.collapseGroup=function(c){b.prototype.collapseGroup.call(this,c),Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED,{instanceid:a})}}}});

View File

@ -23,8 +23,20 @@
*/
define(['jquery', 'core/tree'], function($, Tree) {
return {
init: function() {
new Tree(".block_navigation .block_tree");
init: function(instanceid) {
var navTree = new Tree(".block_navigation .block_tree");
navTree.finishExpandingGroup = function(item) {
Tree.prototype.finishExpandingGroup.call(this, item);
Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED, {
instanceid: instanceid
});
};
navTree.collapseGroup = function(item) {
Tree.prototype.collapseGroup.call(this, item);
Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED, {
instanceid: instanceid
});
};
}
};
});

View File

@ -108,8 +108,11 @@ class block_navigation extends block_base {
*/
function get_required_javascript() {
parent::get_required_javascript();
$arguments = array(
'instanceid' => $this->instance->id
);
$this->page->requires->string_for_js('viewallcourses', 'moodle');
$this->page->requires->js_call_amd('block_navigation/navblock', 'init', array());
$this->page->requires->js_call_amd('block_navigation/navblock', 'init', $arguments);
}
/**

View File

@ -1 +1 @@
define(["jquery","core/tree"],function(a,b){return{init:function(a){var c=new b(".block_settings .block_tree");if(a){var d=c.treeRoot.find("#"+a),e=d.children("a").first();e.replaceWith('<span tabindex="0">'+e.html()+"</span>")}}}});
define(["jquery","core/tree"],function(a,b){return{init:function(a,c){var d=new b(".block_settings .block_tree");if(c){var e=d.treeRoot.find("#"+c),f=e.children("a").first();f.replaceWith('<span tabindex="0">'+f.html()+"</span>")}d.finishExpandingGroup=function(c){b.prototype.finishExpandingGroup.call(this,c),Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED,{instanceid:a})},d.collapseGroup=function(c){b.prototype.collapseGroup.call(this,c),Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED,{instanceid:a})}}}});

View File

@ -16,20 +16,32 @@
/**
* Load the settings block tree javscript
*
* @module block_navigation/navblock
* @module block_settings/settingsblock
* @package core
* @copyright 2015 John Okely <john@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define(['jquery', 'core/tree'], function($, Tree) {
return {
init: function(siteAdminNodeId) {
init: function(instanceid, siteAdminNodeId) {
var adminTree = new Tree(".block_settings .block_tree");
if (siteAdminNodeId) {
var siteAdminNode = adminTree.treeRoot.find('#' + siteAdminNodeId);
var siteAdminLink = siteAdminNode.children('a').first();
siteAdminLink.replaceWith('<span tabindex="0">' + siteAdminLink.html() + '</span>');
}
adminTree.finishExpandingGroup = function(item) {
Tree.prototype.finishExpandingGroup.call(this, item);
Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED, {
instanceid: instanceid
});
};
adminTree.collapseGroup = function(item) {
Tree.prototype.collapseGroup.call(this, item);
Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED, {
instanceid: instanceid
});
};
}
};
});

View File

@ -91,18 +91,13 @@ class block_settings extends block_base {
function get_required_javascript() {
global $PAGE;
$adminnodeid = null;
$adminnode = $PAGE->settingsnav->find('siteadministration', navigation_node::TYPE_SITE_ADMIN);
if (!empty($adminnode)) {
$adminnodeid = $adminnode->id;
}
parent::get_required_javascript();
$arguments = array(
'id' => $this->instance->id,
'instance' => $this->instance->id,
'candock' => $this->instance_can_be_docked()
'instanceid' => $this->instance->id,
'adminnodeid' => $adminnode ? $adminnode->id : null
);
$this->page->requires->js_call_amd('block_settings/settingsblock', 'init', array($adminnodeid));
$this->page->requires->js_call_amd('block_settings/settingsblock', 'init', $arguments);
}
/**

View File

@ -64,6 +64,9 @@ M.core.dock._dockableblocks = {};
*/
M.core.dock.init = function() {
Y.all(SELECTOR.dockableblock).each(M.core.dock.registerDockableBlock);
Y.Global.on(M.core.globalEvents.BLOCK_CONTENT_UPDATED, function(e) {
M.core.dock.notifyBlockChange(e.instanceid);
}, this);
BODY.delegate('click', M.core.dock.dockBlock, SELECTOR.blockmoveto);
BODY.delegate('key', M.core.dock.dockBlock, SELECTOR.blockmoveto, 'enter');
};
@ -2207,6 +2210,7 @@ Y.augment(DOCKEDITEM, Y.EventTarget);
"event-mouseenter",
"event-resize",
"escape",
"moodle-core-dock-loader"
"moodle-core-dock-loader",
"moodle-core-event"
]
});

File diff suppressed because one or more lines are too long

View File

@ -64,6 +64,9 @@ M.core.dock._dockableblocks = {};
*/
M.core.dock.init = function() {
Y.all(SELECTOR.dockableblock).each(M.core.dock.registerDockableBlock);
Y.Global.on(M.core.globalEvents.BLOCK_CONTENT_UPDATED, function(e) {
M.core.dock.notifyBlockChange(e.instanceid);
}, this);
BODY.delegate('click', M.core.dock.dockBlock, SELECTOR.blockmoveto);
BODY.delegate('key', M.core.dock.dockBlock, SELECTOR.blockmoveto, 'enter');
};
@ -2186,6 +2189,7 @@ Y.augment(DOCKEDITEM, Y.EventTarget);
"event-mouseenter",
"event-resize",
"escape",
"moodle-core-dock-loader"
"moodle-core-dock-loader",
"moodle-core-event"
]
});

View File

@ -52,7 +52,15 @@ M.core.globalEvents = M.core.globalEvents || {
* @param formid {string} Id of form with error.
* @param elementid {string} Id of element with error.
*/
FORM_ERROR: "form_error"
FORM_ERROR: "form_error",
/**
* This event is triggered when the content of a block has changed
*
* @event "block_content_updated"
* @param instanceid ID of the block instance that was updated
*/
BLOCK_CONTENT_UPDATED: "block_content_updated"
};

View File

@ -1 +1 @@
YUI.add("moodle-core-event",function(e,t){var n="moodle-core-event";M.core=M.core||{},M.core.event=M.core.event||{FILTER_CONTENT_UPDATED:"filter-content-updated"},M.core.globalEvents=M.core.globalEvents||{FORM_ERROR:"form_error"};var r={emitFacade:!0,defaultFn:function(e){},preventedFn:function(e){},stoppedFn:function(e){}},i;for(i in M.core.event)M.core.event.hasOwnProperty(i)&&e.getEvent(M.core.event[i])===null&&e.publish(M.core.event[i],r);for(i in M.core.globalEvents)M.core.globalEvents.hasOwnProperty(i)&&e.Global.getEvent(M.core.globalEvents[i])===null&&e.Global.publish(M.core.globalEvents[i],e.merge(r,{broadcast:!0}))},"@VERSION@",{requires:["event-custom"]});
YUI.add("moodle-core-event",function(e,t){var n="moodle-core-event";M.core=M.core||{},M.core.event=M.core.event||{FILTER_CONTENT_UPDATED:"filter-content-updated"},M.core.globalEvents=M.core.globalEvents||{FORM_ERROR:"form_error",BLOCK_CONTENT_UPDATED:"block_content_updated"};var r={emitFacade:!0,defaultFn:function(e){},preventedFn:function(e){},stoppedFn:function(e){}},i;for(i in M.core.event)M.core.event.hasOwnProperty(i)&&e.getEvent(M.core.event[i])===null&&e.publish(M.core.event[i],r);for(i in M.core.globalEvents)M.core.globalEvents.hasOwnProperty(i)&&e.Global.getEvent(M.core.globalEvents[i])===null&&e.Global.publish(M.core.globalEvents[i],e.merge(r,{broadcast:!0}))},"@VERSION@",{requires:["event-custom"]});

View File

@ -52,7 +52,15 @@ M.core.globalEvents = M.core.globalEvents || {
* @param formid {string} Id of form with error.
* @param elementid {string} Id of element with error.
*/
FORM_ERROR: "form_error"
FORM_ERROR: "form_error",
/**
* This event is triggered when the content of a block has changed
*
* @event "block_content_updated"
* @param instanceid ID of the block instance that was updated
*/
BLOCK_CONTENT_UPDATED: "block_content_updated"
};

View File

@ -62,6 +62,9 @@ M.core.dock._dockableblocks = {};
*/
M.core.dock.init = function() {
Y.all(SELECTOR.dockableblock).each(M.core.dock.registerDockableBlock);
Y.Global.on(M.core.globalEvents.BLOCK_CONTENT_UPDATED, function(e) {
M.core.dock.notifyBlockChange(e.instanceid);
}, this);
BODY.delegate('click', M.core.dock.dockBlock, SELECTOR.blockmoveto);
BODY.delegate('key', M.core.dock.dockBlock, SELECTOR.blockmoveto, 'enter');
};

View File

@ -7,7 +7,8 @@
"event-mouseenter",
"event-resize",
"escape",
"moodle-core-dock-loader"
"moodle-core-dock-loader",
"moodle-core-event"
]
},
"moodle-core-dock-loader": {

View File

@ -50,7 +50,15 @@ M.core.globalEvents = M.core.globalEvents || {
* @param formid {string} Id of form with error.
* @param elementid {string} Id of element with error.
*/
FORM_ERROR: "form_error"
FORM_ERROR: "form_error",
/**
* This event is triggered when the content of a block has changed
*
* @event "block_content_updated"
* @param instanceid ID of the block instance that was updated
*/
BLOCK_CONTENT_UPDATED: "block_content_updated"
};