From 858fc79db8f3dec7705ff724b1a70c0c0bfca241 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 10 Jul 2013 16:23:46 +1200 Subject: [PATCH] MDL-40368 tool_capability: fixed regression marking single result selected --- .../moodle-tool_capability-search-debug.js | 2 ++ .../moodle-tool_capability-search-min.js | 2 +- .../moodle-tool_capability-search.js | 2 ++ admin/tool/capability/yui/src/search/js/search.js | 3 ++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js index f0661d5e3e4..7a225764d90 100644 --- a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js +++ b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js @@ -122,6 +122,7 @@ SEARCH.prototype = { for (capability in this.selectoptions) { if (capability.indexOf(search) >= 0) { matching++; + last = this.selectoptions[capability]; this.select.append(this.selectoptions[capability]); } } @@ -160,4 +161,5 @@ M.tool_capability.init_capability_search = function(options) { new SEARCH(options); }; + }, '@VERSION@', {"requires": ["base", "node"]}); diff --git a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js index 0153975a401..8b040926b74 100644 --- a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js +++ b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js @@ -1 +1 @@ -YUI.add("moodle-tool_capability-search",function(e,t){var n=function(){n.superclass.constructor.apply(this,arguments)};n.prototype={form:null,select:null,selectoptions:{},input:null,button:null,lastsearch:null,initializer:function(){this.form=e.one("#capability-overview-form"),this.select=this.form.one("select[data-search=capability]"),this.select.setStyle("minWidth",this.select.get("offsetWidth")),this.select.get("options").each(function(e){var t=e.get("value");this.selectoptions[t]=e},this),this.button=this.form.all("input[type=submit]"),this.lastsearch=this.form.one("input[name=search]");var t=e.Node.create('
'),n=e.Node.create('");this.input=e.Node.create(''),t.append(n).append(this.input),this.select.insert(t,"before"),this.select.one("option").setStyle("display","none"),this.input.on("keyup",this.typed,this),this.select.on("change",this.validate,this),this.lastsearch&&(this.input.set("value",this.lastsearch.get("value")),this.typed(),this.select.one("option[selected]")&&this.select.set("scrollTop",this.select.one("option[selected]").get("getX"))),this.validate()},validate:function(){this.button.set("disabled",this.select.get("value")==="")},typed:function(){var e=this.input.get("value"),t=0,n=null,r;this.lastsearch&&this.lastsearch.set("value",e),this.select.all("option").remove();for(r in this.selectoptions)r.indexOf(e)>=0&&(t++,this.select.append(this.selectoptions[r]));t===0?this.input.addClass("error"):(this.input.removeClass("error"),t===1&&n.set("selected",!0)),this.validate()}},e.extend(n,e.Base,n.prototype,{NAME:"tool_capability-search",ATTRS:{strsearch:{}}}),M.tool_capability=M.tool_capability||{},M.tool_capability.init_capability_search=function(e){new n(e)}},"@VERSION@",{requires:["base","node"]}); +YUI.add("moodle-tool_capability-search",function(e,t){var n=function(){n.superclass.constructor.apply(this,arguments)};n.prototype={form:null,select:null,selectoptions:{},input:null,button:null,lastsearch:null,initializer:function(){this.form=e.one("#capability-overview-form"),this.select=this.form.one("select[data-search=capability]"),this.select.setStyle("minWidth",this.select.get("offsetWidth")),this.select.get("options").each(function(e){var t=e.get("value");this.selectoptions[t]=e},this),this.button=this.form.all("input[type=submit]"),this.lastsearch=this.form.one("input[name=search]");var t=e.Node.create('
'),n=e.Node.create('");this.input=e.Node.create(''),t.append(n).append(this.input),this.select.insert(t,"before"),this.select.one("option").setStyle("display","none"),this.input.on("keyup",this.typed,this),this.select.on("change",this.validate,this),this.lastsearch&&(this.input.set("value",this.lastsearch.get("value")),this.typed(),this.select.one("option[selected]")&&this.select.set("scrollTop",this.select.one("option[selected]").get("getX"))),this.validate()},validate:function(){this.button.set("disabled",this.select.get("value")==="")},typed:function(){var e=this.input.get("value"),t=0,n=null,r;this.lastsearch&&this.lastsearch.set("value",e),this.select.all("option").remove();for(r in this.selectoptions)r.indexOf(e)>=0&&(t++,n=this.selectoptions[r],this.select.append(this.selectoptions[r]));t===0?this.input.addClass("error"):(this.input.removeClass("error"),t===1&&n.set("selected",!0)),this.validate()}},e.extend(n,e.Base,n.prototype,{NAME:"tool_capability-search",ATTRS:{strsearch:{}}}),M.tool_capability=M.tool_capability||{},M.tool_capability.init_capability_search=function(e){new n(e)}},"@VERSION@",{requires:["base","node"]}); diff --git a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search.js b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search.js index f0661d5e3e4..7a225764d90 100644 --- a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search.js +++ b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search.js @@ -122,6 +122,7 @@ SEARCH.prototype = { for (capability in this.selectoptions) { if (capability.indexOf(search) >= 0) { matching++; + last = this.selectoptions[capability]; this.select.append(this.selectoptions[capability]); } } @@ -160,4 +161,5 @@ M.tool_capability.init_capability_search = function(options) { new SEARCH(options); }; + }, '@VERSION@', {"requires": ["base", "node"]}); diff --git a/admin/tool/capability/yui/src/search/js/search.js b/admin/tool/capability/yui/src/search/js/search.js index 5e9dc3460b4..53949416e90 100644 --- a/admin/tool/capability/yui/src/search/js/search.js +++ b/admin/tool/capability/yui/src/search/js/search.js @@ -120,6 +120,7 @@ SEARCH.prototype = { for (capability in this.selectoptions) { if (capability.indexOf(search) >= 0) { matching++; + last = this.selectoptions[capability]; this.select.append(this.selectoptions[capability]); } } @@ -156,4 +157,4 @@ M.tool_capability = M.tool_capability || {}; */ M.tool_capability.init_capability_search = function(options) { new SEARCH(options); -}; \ No newline at end of file +};