mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
MDL-45758 tool_monitor: YUI module to handle event selection dropdown
Original issue - MDL-45938
This commit is contained in:
parent
48cc3a8d4d
commit
2fd010b886
6 changed files with 291 additions and 0 deletions
92
admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-debug.js
vendored
Normal file
92
admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-debug.js
vendored
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
YUI.add('moodle-tool_monitor-dropdown', function (Y, NAME) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A module to manage dropdowns on the rule add/edit form.
|
||||||
|
*
|
||||||
|
* @module moodle-tool_monitor-dropdown
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A module to manage dependent selects on the edit page.
|
||||||
|
*
|
||||||
|
* @since Moodle 2.8
|
||||||
|
* @class moodle-tool_monitor.dropdown
|
||||||
|
* @extends Base
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function DropDown() {
|
||||||
|
DropDown.superclass.constructor.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var SELECTORS = {
|
||||||
|
PLUGIN: '#id_plugin',
|
||||||
|
EVENTNAME: '#id_eventname',
|
||||||
|
OPTION: 'option',
|
||||||
|
CHOOSE: 'option[value=""]'
|
||||||
|
};
|
||||||
|
|
||||||
|
Y.extend(DropDown, Y.Base, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to the plugin node.
|
||||||
|
*
|
||||||
|
* @property plugin
|
||||||
|
* @type Object
|
||||||
|
* @default null
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
plugin: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to the plugin node.
|
||||||
|
*
|
||||||
|
* @property eventname
|
||||||
|
* @type Object
|
||||||
|
* @default null
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
eventname: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializer.
|
||||||
|
* Basic setup and delegations.
|
||||||
|
*
|
||||||
|
* @method initializer
|
||||||
|
*/
|
||||||
|
initializer: function() {
|
||||||
|
this.plugin = Y.one(SELECTORS.PLUGIN);
|
||||||
|
this.eventname = Y.one(SELECTORS.EVENTNAME);
|
||||||
|
this.plugin.on('change', this.updateEventsList, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to update the events list drop down when plugin list drop down is changed.
|
||||||
|
*
|
||||||
|
* @method updateEventsList
|
||||||
|
*/
|
||||||
|
updateEventsList: function() {
|
||||||
|
var plugin = this.plugin.get('value'); // Get component name.
|
||||||
|
var namespace = '\\' + plugin + '\\';
|
||||||
|
this.eventname.all(SELECTORS.OPTION).hide(); // Hide all options.
|
||||||
|
this.eventname.all(SELECTORS.OPTION).each(function(node) {
|
||||||
|
// Make sure we highlight only nodes with correct namespace.
|
||||||
|
if (node.get('value').substring(0, namespace.length) === namespace) {
|
||||||
|
node.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Mark the default choose node as visible and selected.
|
||||||
|
var choosenode = this.eventname.one(SELECTORS.CHOOSE);
|
||||||
|
choosenode.show().set('selected', 'selected');
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
NAME: 'dropDown',
|
||||||
|
ATTRS: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
Y.namespace('M.tool_monitor.DropDown').init = function(config) {
|
||||||
|
return new DropDown(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}, '@VERSION@', {"requires": ["base", "event", "node"]});
|
|
@ -0,0 +1 @@
|
||||||
|
YUI.add("moodle-tool_monitor-dropdown",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}var r={PLUGIN:"#id_plugin",EVENTNAME:"#id_eventname",OPTION:"option",CHOOSE:'option[value=""]'};e.extend(n,e.Base,{plugin:null,eventname:null,initializer:function(){this.plugin=e.one(r.PLUGIN),this.eventname=e.one(r.EVENTNAME),this.plugin.on("change",this.updateEventsList,this)},updateEventsList:function(){var e=this.plugin.get("value"),t="\\"+e+"\\";this.eventname.all(r.OPTION).hide(),this.eventname.all(r.OPTION).each(function(e){e.get("value").substring(0,t.length)===t&&e.show()});var n=this.eventname.one(r.CHOOSE);n.show().set("selected","selected")}},{NAME:"dropDown",ATTRS:{}}),e.namespace("M.tool_monitor.DropDown").init=function(e){return new n(e)}},"@VERSION@",{requires:["base","event","node"]});
|
92
admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown.js
vendored
Normal file
92
admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown.js
vendored
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
YUI.add('moodle-tool_monitor-dropdown', function (Y, NAME) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A module to manage dropdowns on the rule add/edit form.
|
||||||
|
*
|
||||||
|
* @module moodle-tool_monitor-dropdown
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A module to manage dependent selects on the edit page.
|
||||||
|
*
|
||||||
|
* @since Moodle 2.8
|
||||||
|
* @class moodle-tool_monitor.dropdown
|
||||||
|
* @extends Base
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function DropDown() {
|
||||||
|
DropDown.superclass.constructor.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var SELECTORS = {
|
||||||
|
PLUGIN: '#id_plugin',
|
||||||
|
EVENTNAME: '#id_eventname',
|
||||||
|
OPTION: 'option',
|
||||||
|
CHOOSE: 'option[value=""]'
|
||||||
|
};
|
||||||
|
|
||||||
|
Y.extend(DropDown, Y.Base, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to the plugin node.
|
||||||
|
*
|
||||||
|
* @property plugin
|
||||||
|
* @type Object
|
||||||
|
* @default null
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
plugin: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to the plugin node.
|
||||||
|
*
|
||||||
|
* @property eventname
|
||||||
|
* @type Object
|
||||||
|
* @default null
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
eventname: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializer.
|
||||||
|
* Basic setup and delegations.
|
||||||
|
*
|
||||||
|
* @method initializer
|
||||||
|
*/
|
||||||
|
initializer: function() {
|
||||||
|
this.plugin = Y.one(SELECTORS.PLUGIN);
|
||||||
|
this.eventname = Y.one(SELECTORS.EVENTNAME);
|
||||||
|
this.plugin.on('change', this.updateEventsList, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to update the events list drop down when plugin list drop down is changed.
|
||||||
|
*
|
||||||
|
* @method updateEventsList
|
||||||
|
*/
|
||||||
|
updateEventsList: function() {
|
||||||
|
var plugin = this.plugin.get('value'); // Get component name.
|
||||||
|
var namespace = '\\' + plugin + '\\';
|
||||||
|
this.eventname.all(SELECTORS.OPTION).hide(); // Hide all options.
|
||||||
|
this.eventname.all(SELECTORS.OPTION).each(function(node) {
|
||||||
|
// Make sure we highlight only nodes with correct namespace.
|
||||||
|
if (node.get('value').substring(0, namespace.length) === namespace) {
|
||||||
|
node.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Mark the default choose node as visible and selected.
|
||||||
|
var choosenode = this.eventname.one(SELECTORS.CHOOSE);
|
||||||
|
choosenode.show().set('selected', 'selected');
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
NAME: 'dropDown',
|
||||||
|
ATTRS: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
Y.namespace('M.tool_monitor.DropDown').init = function(config) {
|
||||||
|
return new DropDown(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}, '@VERSION@', {"requires": ["base", "event", "node"]});
|
10
admin/tool/monitor/yui/src/dropdown/build.json
Normal file
10
admin/tool/monitor/yui/src/dropdown/build.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"name": "moodle-tool_monitor-dropdown",
|
||||||
|
"builds": {
|
||||||
|
"moodle-tool_monitor-dropdown": {
|
||||||
|
"jsfiles": [
|
||||||
|
"dropdown.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
87
admin/tool/monitor/yui/src/dropdown/js/dropdown.js
vendored
Normal file
87
admin/tool/monitor/yui/src/dropdown/js/dropdown.js
vendored
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/**
|
||||||
|
* A module to manage dropdowns on the rule add/edit form.
|
||||||
|
*
|
||||||
|
* @module moodle-tool_monitor-dropdown
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A module to manage dependent selects on the edit page.
|
||||||
|
*
|
||||||
|
* @since Moodle 2.8
|
||||||
|
* @class moodle-tool_monitor.dropdown
|
||||||
|
* @extends Base
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function DropDown() {
|
||||||
|
DropDown.superclass.constructor.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var SELECTORS = {
|
||||||
|
PLUGIN: '#id_plugin',
|
||||||
|
EVENTNAME: '#id_eventname',
|
||||||
|
OPTION: 'option',
|
||||||
|
CHOOSE: 'option[value=""]'
|
||||||
|
};
|
||||||
|
|
||||||
|
Y.extend(DropDown, Y.Base, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to the plugin node.
|
||||||
|
*
|
||||||
|
* @property plugin
|
||||||
|
* @type Object
|
||||||
|
* @default null
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
plugin: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to the plugin node.
|
||||||
|
*
|
||||||
|
* @property eventname
|
||||||
|
* @type Object
|
||||||
|
* @default null
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
eventname: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializer.
|
||||||
|
* Basic setup and delegations.
|
||||||
|
*
|
||||||
|
* @method initializer
|
||||||
|
*/
|
||||||
|
initializer: function() {
|
||||||
|
this.plugin = Y.one(SELECTORS.PLUGIN);
|
||||||
|
this.eventname = Y.one(SELECTORS.EVENTNAME);
|
||||||
|
this.plugin.on('change', this.updateEventsList, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to update the events list drop down when plugin list drop down is changed.
|
||||||
|
*
|
||||||
|
* @method updateEventsList
|
||||||
|
*/
|
||||||
|
updateEventsList: function() {
|
||||||
|
var plugin = this.plugin.get('value'); // Get component name.
|
||||||
|
var namespace = '\\' + plugin + '\\';
|
||||||
|
this.eventname.all(SELECTORS.OPTION).hide(); // Hide all options.
|
||||||
|
this.eventname.all(SELECTORS.OPTION).each(function(node) {
|
||||||
|
// Make sure we highlight only nodes with correct namespace.
|
||||||
|
if (node.get('value').substring(0, namespace.length) === namespace) {
|
||||||
|
node.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Mark the default choose node as visible and selected.
|
||||||
|
var choosenode = this.eventname.one(SELECTORS.CHOOSE);
|
||||||
|
choosenode.show().set('selected', 'selected');
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
NAME: 'dropDown',
|
||||||
|
ATTRS: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
Y.namespace('M.tool_monitor.DropDown').init = function(config) {
|
||||||
|
return new DropDown(config);
|
||||||
|
};
|
9
admin/tool/monitor/yui/src/dropdown/meta/dropdown.json
Normal file
9
admin/tool/monitor/yui/src/dropdown/meta/dropdown.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"moodle-tool_monitor-dropdown": {
|
||||||
|
"requires": [
|
||||||
|
"base",
|
||||||
|
"event",
|
||||||
|
"node"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue