From 1bd19d00ed60712c9b0cf1de7089da7765d2632a Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 21 May 2013 23:25:34 +0800 Subject: Bug 874464: unable to file bugs with the guided bug entry form using IE --- .../template/en/default/guided/guided.html.tmpl | 2 +- .../ProdCompSearch/web/js/prod_comp_search.js | 202 +++++++++++---------- 2 files changed, 103 insertions(+), 101 deletions(-) diff --git a/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl b/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl index 849df4c47..ff3ecbc11 100644 --- a/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl +++ b/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl @@ -70,7 +70,7 @@ dupes.setLabels( id: "[% field_descs.bug_id FILTER js %]", summary: "[% field_descs.short_desc FILTER js %]", component: "[% field_descs.component FILTER js %]", - status: "[% field_descs.bug_status FILTER js %]", + status: "[% field_descs.bug_status FILTER js %]" } ); diff --git a/extensions/ProdCompSearch/web/js/prod_comp_search.js b/extensions/ProdCompSearch/web/js/prod_comp_search.js index f6c3f011c..cb4a50ccc 100644 --- a/extensions/ProdCompSearch/web/js/prod_comp_search.js +++ b/extensions/ProdCompSearch/web/js/prod_comp_search.js @@ -19,119 +19,121 @@ YUI({ base: 'js/yui3/', combine: false }).use("node", "json-stringify", "autocomplete", "escape", - "datasource-io", "datasource-jsonschema", function (Y) { - var counter = 0, - dataSource = null, - autoComplete = null; + "datasource-io", "datasource-jsonschema", function(Y) { + Y.on("domready", function() { + var counter = 0, + dataSource = null, + autoComplete = null; - var resultListFormat = function(query, results) { - return Y.Array.map(results, function(result) { - var data = result.raw; - result.text = data.product + ' :: ' + data.component; - return Y.Escape.html(result.text); - }); - }; + var resultListFormat = function(query, results) { + return Y.Array.map(results, function(result) { + var data = result.raw; + result.text = data.product + ' :: ' + data.component; + return Y.Escape.html(result.text); + }); + }; - var requestTemplate = function(query) { - counter = counter + 1; - var json_object = { - version: "1.1", - method : "PCS.prod_comp_search", - id : counter, - params : { search: query } + var requestTemplate = function(query) { + counter = counter + 1; + var json_object = { + version: "1.1", + method : "PCS.prod_comp_search", + id : counter, + params : { search: query } + }; + return Y.JSON.stringify(json_object); }; - return Y.JSON.stringify(json_object); - }; - var dataSource = new Y.DataSource.IO({ - source: 'jsonrpc.cgi', - ioConfig: { - method: "POST", - headers: { 'Content-Type': 'application/json' } - }, - on: { - error: function(e) { - if (console.error && e.response.meta.error) { - console.error(e.response.meta.error.message); + var dataSource = new Y.DataSource.IO({ + source: 'jsonrpc.cgi', + ioConfig: { + method: "POST", + headers: { 'Content-Type': 'application/json' } + }, + on: { + error: function(e) { + if (console.error && e.response.meta.error) { + console.error(e.response.meta.error.message); + } + Y.one("#prod_comp_throbber").addClass('bz_default_hidden'); + Y.one("#prod_comp_error").removeClass('bz_default_hidden'); } - Y.one("#prod_comp_throbber").addClass('bz_default_hidden'); - Y.one("#prod_comp_error").removeClass('bz_default_hidden'); } - } - }); + }); - dataSource.plug(Y.Plugin.DataSourceJSONSchema, { - schema: { - resultListLocator : "result.products", - resultFields : [ "product", "component" ], - metaFields : { error : 'error' } - } - }); + dataSource.plug(Y.Plugin.DataSourceJSONSchema, { + schema: { + resultListLocator : "result.products", + resultFields : [ "product", "component" ], + metaFields : { error : 'error' } + } + }); - var input = Y.one('#prod_comp_search'); + var input = Y.one('#prod_comp_search'); - input.plug(Y.Plugin.AutoComplete, { - activateFirstItem: false, - enableCache: true, - source: dataSource, - minQueryLength: 3, - queryDelay: 0.05, - resultFormatter: resultListFormat, - suppressInputUpdate: true, - maxResults: 25, - scrollIntoView: true, - requestTemplate: requestTemplate, - on: { - query: function(e) { - Y.one("#prod_comp_throbber").removeClass('bz_default_hidden'); - Y.one("#prod_comp_no_components").addClass('bz_default_hidden'); - Y.one("#prod_comp_error").addClass('bz_default_hidden'); - }, - results: function(e) { - Y.one("#prod_comp_throbber").addClass('bz_default_hidden'); - input.ac.set('activateFirstItem', e.results.length == 1); - if (e.results.length == 0) { - Y.one("#prod_comp_no_components").removeClass('bz_default_hidden'); - } - }, - select: function(e) { - // Only redirect if the script_name is a valid choice - if (Y.Array.indexOf(ProdCompSearch.script_choices, ProdCompSearch.script_name) == -1) - return; + input.plug(Y.Plugin.AutoComplete, { + activateFirstItem: false, + enableCache: true, + source: dataSource, + minQueryLength: 3, + queryDelay: 0.05, + resultFormatter: resultListFormat, + suppressInputUpdate: true, + maxResults: 25, + scrollIntoView: true, + requestTemplate: requestTemplate, + on: { + query: function(e) { + Y.one("#prod_comp_throbber").removeClass('bz_default_hidden'); + Y.one("#prod_comp_no_components").addClass('bz_default_hidden'); + Y.one("#prod_comp_error").addClass('bz_default_hidden'); + }, + results: function(e) { + Y.one("#prod_comp_throbber").addClass('bz_default_hidden'); + input.ac.set('activateFirstItem', e.results.length == 1); + if (e.results.length == 0) { + Y.one("#prod_comp_no_components").removeClass('bz_default_hidden'); + } + }, + select: function(e) { + // Only redirect if the script_name is a valid choice + if (Y.Array.indexOf(ProdCompSearch.script_choices, ProdCompSearch.script_name) == -1) + return; - var data = e.result.raw; - var url = ProdCompSearch.script_name + - "?product=" + encodeURIComponent(data.product) + - "&component=" + encodeURIComponent(data.component); - if (ProdCompSearch.script_name == 'enter_bug.cgi') { - if (ProdCompSearch.format) - url += "&format=" + encodeURIComponent(ProdCompSearch.format); - if (ProdCompSearch.cloned_bug_id) - url += "&cloned_bug_id=" + encodeURIComponent(ProdCompSearch.cloned_bug_id); - } - if (ProdCompSearch.script_name == 'describecomponents.cgi') { - url += "#" + encodeURIComponent(data.component); - } - if (ProdCompSearch.new_tab) { - window.open(url, '_blank'); + var data = e.result.raw; + var url = ProdCompSearch.script_name + + "?product=" + encodeURIComponent(data.product) + + "&component=" + encodeURIComponent(data.component); + if (ProdCompSearch.script_name == 'enter_bug.cgi') { + if (ProdCompSearch.format) + url += "&format=" + encodeURIComponent(ProdCompSearch.format); + if (ProdCompSearch.cloned_bug_id) + url += "&cloned_bug_id=" + encodeURIComponent(ProdCompSearch.cloned_bug_id); + } + if (ProdCompSearch.script_name == 'describecomponents.cgi') { + url += "#" + encodeURIComponent(data.component); + } + if (ProdCompSearch.new_tab) { + window.open(url, '_blank'); + } + else { + window.location.href = url; + } } - else { - window.location.href = url; - } - } - }, - after: { - select: function(e) { - if (ProdCompSearch.new_tab) { - input.set('value',''); + }, + after: { + select: function(e) { + if (ProdCompSearch.new_tab) { + input.set('value',''); + } } } - } - }); + }); - input.on('focus', function (e) { - if (e.target.value && e.target.value.length > 3) { - dataSource.load(e.target.value); - } + input.on('focus', function (e) { + if (e.target.value && e.target.value.length > 3) { + dataSource.load(e.target.value); + } + }); }); }); -- cgit v1.2.3-24-g4f1b