MDL-45758 tool_monitor: Update js to get around chrome bug

This commit is contained in:
Ankit Agarwal
2014-10-15 07:41:06 +05:30
parent 75cae53b7b
commit e8a925a60e
6 changed files with 90 additions and 37 deletions
-2
View File
@@ -46,8 +46,6 @@ class rule_form extends \moodleform {
$pluginlist = $this->_customdata['pluginlist'];
$rule = $this->_customdata['rule'];
$courseid = $this->_customdata['courseid'];
$eventlist = array_merge(array('' => get_string('choosedots')), $eventlist);
$pluginlist = array_merge(array('' => get_string('choosedots')), $pluginlist);
// General section header.
$mform->addElement('header', 'general', get_string('general'));
+11 -4
View File
@@ -55,7 +55,16 @@ $PAGE->set_url($url);
$PAGE->set_pagelayout('report');
$PAGE->set_title($title);
$PAGE->set_heading($title);
$PAGE->requires->yui_module('moodle-tool_monitor-dropdown', 'Y.M.tool_monitor.DropDown.init');
// Get data ready for mform.
$eventlist = tool_monitor\eventlist::get_all_eventlist(true);
$pluginlist = tool_monitor\eventlist::get_plugin_list();
$eventlist = array_merge(array('' => get_string('choosedots')), $eventlist);
$pluginlist = array_merge(array('' => get_string('choosedots')), $pluginlist);
// Set up the yui module.
$PAGE->requires->yui_module('moodle-tool_monitor-dropdown', 'Y.M.tool_monitor.DropDown.init',
array(array('eventlist' => $eventlist)));
// Site level report.
if (empty($courseid)) {
@@ -65,9 +74,7 @@ if (empty($courseid)) {
$PAGE->navigation->override_active_url($manageurl);
}
// Get data ready for mform.
$eventlist = tool_monitor\eventlist::get_all_eventlist(true);
$pluginlist = tool_monitor\eventlist::get_plugin_list();
// Mform setup.
if (!empty($ruleid)) {
$rule = \tool_monitor\rule_manager::get_rule($ruleid)->get_mform_set_data();
$rule->minutes = $rule->timewindow / MINSECS;
@@ -66,22 +66,38 @@ Y.extend(DropDown, Y.Base, {
* @method updateEventsList
*/
updateEventsList: function() {
var node, options, choosenode;
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();
}
});
this.eventname.all(SELECTORS.OPTION).remove(true); // Delete all nodes.
options = this.get('eventlist');
// Mark the default choose node as visible and selected.
var choosenode = this.eventname.one(SELECTORS.CHOOSE);
choosenode.show().set('selected', 'selected');
choosenode = Y.Node.create('<option value="">' + options[''] + '</option>');
choosenode.set('selected', 'selected');
this.eventname.appendChild(choosenode);
Y.Object.each(options, function(value, key) {
// Make sure we highlight only nodes with correct namespace.
if (key.substring(0, namespace.length) === namespace) {
node = Y.Node.create('<option value="' + key + '">' + value + '</option>');
this.eventname.appendChild(node);
}
}, this);
}
}, {
NAME: 'dropDown',
ATTRS: {}
ATTRS: {
/**
* A list of events with components.
*
* @attribute eventlist
* @default null
* @type Object
*/
eventlist: null
}
});
Y.namespace('M.tool_monitor.DropDown').init = function(config) {
@@ -1 +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"]});
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 t,n,i,s=this.plugin.get("value"),o="\\"+s+"\\";this.eventname.all(r.OPTION).remove(!0),n=this.get("eventlist"),i=e.Node.create('<option value="">'+n[""]+"</option>"),i.set("selected","selected"),this.eventname.appendChild(i),e.Object.each(n,function(n,r){r.substring(0,o.length)===o&&(t=e.Node.create('<option value="'+r+'">'+n+"</option>"),this.eventname.appendChild(t))},this)}},{NAME:"dropDown",ATTRS:{eventlist:null}}),e.namespace("M.tool_monitor.DropDown").init=function(e){return new n(e)}},"@VERSION@",{requires:["base","event","node"]});
@@ -66,22 +66,38 @@ Y.extend(DropDown, Y.Base, {
* @method updateEventsList
*/
updateEventsList: function() {
var node, options, choosenode;
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();
}
});
this.eventname.all(SELECTORS.OPTION).remove(true); // Delete all nodes.
options = this.get('eventlist');
// Mark the default choose node as visible and selected.
var choosenode = this.eventname.one(SELECTORS.CHOOSE);
choosenode.show().set('selected', 'selected');
choosenode = Y.Node.create('<option value="">' + options[''] + '</option>');
choosenode.set('selected', 'selected');
this.eventname.appendChild(choosenode);
Y.Object.each(options, function(value, key) {
// Make sure we highlight only nodes with correct namespace.
if (key.substring(0, namespace.length) === namespace) {
node = Y.Node.create('<option value="' + key + '">' + value + '</option>');
this.eventname.appendChild(node);
}
}, this);
}
}, {
NAME: 'dropDown',
ATTRS: {}
ATTRS: {
/**
* A list of events with components.
*
* @attribute eventlist
* @default null
* @type Object
*/
eventlist: null
}
});
Y.namespace('M.tool_monitor.DropDown').init = function(config) {
+26 -10
View File
@@ -64,22 +64,38 @@ Y.extend(DropDown, Y.Base, {
* @method updateEventsList
*/
updateEventsList: function() {
var node, options, choosenode;
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();
}
});
this.eventname.all(SELECTORS.OPTION).remove(true); // Delete all nodes.
options = this.get('eventlist');
// Mark the default choose node as visible and selected.
var choosenode = this.eventname.one(SELECTORS.CHOOSE);
choosenode.show().set('selected', 'selected');
choosenode = Y.Node.create('<option value="">' + options[''] + '</option>');
choosenode.set('selected', 'selected');
this.eventname.appendChild(choosenode);
Y.Object.each(options, function(value, key) {
// Make sure we highlight only nodes with correct namespace.
if (key.substring(0, namespace.length) === namespace) {
node = Y.Node.create('<option value="' + key + '">' + value + '</option>');
this.eventname.appendChild(node);
}
}, this);
}
}, {
NAME: 'dropDown',
ATTRS: {}
ATTRS: {
/**
* A list of events with components.
*
* @attribute eventlist
* @default null
* @type Object
*/
eventlist: null
}
});
Y.namespace('M.tool_monitor.DropDown').init = function(config) {