From 81bd56ad4f9eb261597ef795a19097f4d93c155b Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 24 Jan 2010 18:11:25 +0000 Subject: [PATCH] MDL-21400 improved coding style --- admin/report/capability/module.js | 33 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/admin/report/capability/module.js b/admin/report/capability/module.js index f646db14a09..89fdd02069a 100644 --- a/admin/report/capability/module.js +++ b/admin/report/capability/module.js @@ -5,9 +5,11 @@ M.report_capability = { button: null, init: function(Y, strsearch) { + var context = M.report_capability; + // Find the form controls. - M.report_capability.select = document.getElementById('menucapability'); - M.report_capability.button = document.getElementById('settingssubmit'); + context.select = document.getElementById('menucapability'); + context.button = document.getElementById('settingssubmit'); // Create a div to hold the search UI. var div = document.createElement('div'); @@ -17,7 +19,7 @@ M.report_capability = { var input = document.createElement('input'); input.type = 'text'; input.id = 'capabilitysearch'; - M.report_capability.input = input; + context.input = input; // Create a label for the search input. var label = document.createElement('label'); @@ -27,16 +29,18 @@ M.report_capability = { // Tie it all together div.appendChild(label); div.appendChild(input); - M.report_capability.select.parentNode.insertBefore(div, M.report_capability.select); - Y.on('keyup', M.report_capability.typed, input); - Y.on('change', M.report_capability.validate, M.report_capability.select); - M.report_capability.select.options[0].style.display = 'none'; - M.report_capability.validate(); + context.select.parentNode.insertBefore(div, context.select); + Y.on('keyup', context.typed, input); + Y.on('change', context.validate, context.select); + context.select.options[0].style.display = 'none'; + context.validate(); }, typed: function() { - var filtertext = M.report_capability.input.value; - var options = M.report_capability.select.options; + var context = M.report_capability; + + var filtertext = context.input.value; + var options = context.select.options; var onlycapability = -1; for (var i = 1; i < options.length; i++) { if (options[i].text.indexOf(filtertext) >= 0) { @@ -57,14 +61,15 @@ M.report_capability = { options[onlycapability].selected = true; } if (onlycapability == -1) { - M.report_capability.input.className = "error"; + context.input.className = "error"; } else { - M.report_capability.input.className = ""; + context.input.className = ""; } - M.report_capability.validate(); + context.validate(); }, validate: function() { - M.report_capability.button.disabled = (M.report_capability.select.value == ''); + var context = M.report_capability; + context.button.disabled = (context.select.value == ''); } } \ No newline at end of file