MDL-47870 tool_monitor: Fix event select dropdown

This commit is contained in:
Ankit Agarwal
2014-10-28 09:49:08 +05:30
parent d63a81c507
commit d71e42d7e8
4 changed files with 52 additions and 1 deletions
@@ -57,6 +57,9 @@ Y.extend(DropDown, Y.Base, {
initializer: function() {
this.plugin = Y.one(SELECTORS.PLUGIN);
this.eventname = Y.one(SELECTORS.EVENTNAME);
var selection = this.eventname.get('value'); // Get selected event name.
this.updateEventsList();
this.updateSelection(selection);
this.plugin.on('change', this.updateEventsList, this);
},
@@ -85,6 +88,20 @@ Y.extend(DropDown, Y.Base, {
}
}, this);
},
/**
* Method to update the selected node from the options list.
*
* @method updateSelection
* @param {string} selection The options node value that should be selected.
*/
updateSelection: function(selection) {
this.eventname.get('options').each(function(opt) {
if (opt.get('value') === selection) {
opt.set('selected', 'selected');
}
}, this);
}
}, {
NAME: 'dropDown',
@@ -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 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"]});
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);var t=this.eventname.get("value");this.updateEventsList(),this.updateSelection(t),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)},updateSelection:function(e){this.eventname.get("options").each(function(t){t.get("value")===e&&t.set("selected","selected")},this)}},{NAME:"dropDown",ATTRS:{eventlist:null}}),e.namespace("M.tool_monitor.DropDown").init=function(e){return new n(e)}},"@VERSION@",{requires:["base","event","node"]});
@@ -57,6 +57,9 @@ Y.extend(DropDown, Y.Base, {
initializer: function() {
this.plugin = Y.one(SELECTORS.PLUGIN);
this.eventname = Y.one(SELECTORS.EVENTNAME);
var selection = this.eventname.get('value'); // Get selected event name.
this.updateEventsList();
this.updateSelection(selection);
this.plugin.on('change', this.updateEventsList, this);
},
@@ -85,6 +88,20 @@ Y.extend(DropDown, Y.Base, {
}
}, this);
},
/**
* Method to update the selected node from the options list.
*
* @method updateSelection
* @param {string} selection The options node value that should be selected.
*/
updateSelection: function(selection) {
this.eventname.get('options').each(function(opt) {
if (opt.get('value') === selection) {
opt.set('selected', 'selected');
}
}, this);
}
}, {
NAME: 'dropDown',
+17
View File
@@ -55,6 +55,9 @@ Y.extend(DropDown, Y.Base, {
initializer: function() {
this.plugin = Y.one(SELECTORS.PLUGIN);
this.eventname = Y.one(SELECTORS.EVENTNAME);
var selection = this.eventname.get('value'); // Get selected event name.
this.updateEventsList();
this.updateSelection(selection);
this.plugin.on('change', this.updateEventsList, this);
},
@@ -83,6 +86,20 @@ Y.extend(DropDown, Y.Base, {
}
}, this);
},
/**
* Method to update the selected node from the options list.
*
* @method updateSelection
* @param {string} selection The options node value that should be selected.
*/
updateSelection: function(selection) {
this.eventname.get('options').each(function(opt) {
if (opt.get('value') === selection) {
opt.set('selected', 'selected');
}
}, this);
}
}, {
NAME: 'dropDown',