From d71e42d7e891f0199143be7de22841c8f622746b Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Mon, 27 Oct 2014 08:00:49 +0530 Subject: [PATCH] MDL-47870 tool_monitor: Fix event select dropdown --- .../moodle-tool_monitor-dropdown-debug.js | 17 +++++++++++++++++ .../moodle-tool_monitor-dropdown-min.js | 2 +- .../moodle-tool_monitor-dropdown.js | 17 +++++++++++++++++ admin/tool/monitor/yui/src/dropdown/js/dropdown.js | 17 +++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) rewrite admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js (67%) diff --git a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-debug.js b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-debug.js index 79184dd7bc1..a11a2be4277 100644 --- a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-debug.js +++ b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-debug.js @@ -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', diff --git a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js dissimilarity index 67% index c62a01318d7..bf740869bd5 100644 --- a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js +++ b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js @@ -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('"),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('"),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('"),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('"),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"]}); diff --git a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown.js b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown.js index 79184dd7bc1..a11a2be4277 100644 --- a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown.js +++ b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown.js @@ -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', diff --git a/admin/tool/monitor/yui/src/dropdown/js/dropdown.js b/admin/tool/monitor/yui/src/dropdown/js/dropdown.js index ff839b6ec42..1dff1afa230 100644 --- a/admin/tool/monitor/yui/src/dropdown/js/dropdown.js +++ b/admin/tool/monitor/yui/src/dropdown/js/dropdown.js @@ -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', -- 2.11.4.GIT