diff options
author | Dave Lawrence <dlawrence@mozilla.com> | 2012-12-08 00:02:03 +0100 |
---|---|---|
committer | Dave Lawrence <dlawrence@mozilla.com> | 2012-12-08 00:02:03 +0100 |
commit | 102c9694ef56fd673fe31729e67b650befb9df44 (patch) | |
tree | da54e655fa5a0e57b13b0c9ddad3ebafe471dc57 /extensions/MyDashboard/web/js/prod_comp_search.js | |
parent | 6827b1d3d99e4e05fc2012896c9e2d941297b7ed (diff) | |
download | bugzilla-102c9694ef56fd673fe31729e67b650befb9df44.tar.gz bugzilla-102c9694ef56fd673fe31729e67b650befb9df44.tar.xz |
Current dashboard work
Diffstat (limited to 'extensions/MyDashboard/web/js/prod_comp_search.js')
-rw-r--r-- | extensions/MyDashboard/web/js/prod_comp_search.js | 99 |
1 files changed, 30 insertions, 69 deletions
diff --git a/extensions/MyDashboard/web/js/prod_comp_search.js b/extensions/MyDashboard/web/js/prod_comp_search.js index db9d47c5c..d56baebec 100644 --- a/extensions/MyDashboard/web/js/prod_comp_search.js +++ b/extensions/MyDashboard/web/js/prod_comp_search.js @@ -19,7 +19,6 @@ YUI({ autoComplete = null; var resultListFormat = function(query, results) { - Y.log(results); return Y.Array.map(results, function (result) { var data = result.raw; return Y.Escape.html(data.product) + " :: " + @@ -27,6 +26,17 @@ YUI({ }); }; + var requestTemplate = function(query) { + counter = counter + 1; + var json_object = { + version: "1.1", + method : "MyDashboard.prod_comp_search", + id : counter, + params : { search: query } + }; + return Y.JSON.stringify(json_object); + }; + var dataSource = new Y.DataSource.IO({ source: 'jsonrpc.cgi', ioConfig: { @@ -37,7 +47,7 @@ YUI({ dataSource.plug(Y.Plugin.DataSourceJSONSchema, { schema: { - resultsListLocator : "result.products", + resultListLocator : "result.products", resultFields : [ "product", "component" ] } }); @@ -53,75 +63,26 @@ YUI({ maxResultsDisplayed: 25, suppressInputUpdate: true, maxResults: 25, - requestTemplate: function (query) { - counter = counter + 1; - var json_object = { - version: "1.1", - method : "MyDashboard.prod_comp_search", - id : counter, - params : { search: query } - }; - return Y.JSON.stringify(json_object); + requestTemplate: requestTemplate, + on: { + query: function() { + Y.one("#prod_comp_throbber").removeClass('bz_default_hidden'); + }, + results: function() { + Y.one("#prod_comp_throbber").addClass('bz_default_hidden'); + }, + select: function(e) { + var data = e.result.raw; + var url = "enter_bug.cgi?product=" + encodeURIComponent(data.product) + + "&component=" + encodeURIComponent(data.component); + window.location.href = url; + } }, -// resultListLocator: 'response.result.products', -// resultListLocator: 'result.products' -// resultListLocator: function (response) { -// Y.log(response); -// return (response && response.data && response.data.result.products) || []; -// }, -// // Makes sure an array is returned even on an error. -// if (response.error) { -// return []; -// } -// -// Y.log(response); -// -// return response.query.results; -// -// return [{ -// product: "Foo", -// component: "Bar" -// }]; -// var query = response.query.results.json, -// addresses; -// -// if (query.status !== 'OK') { -// return []; -// } -// -// // Grab the actual addresses from the YQL query. -// addresses = query.results; -// -// // Makes sure an array is always returned. -// return addresses.length > 0 ? addresses : [addresses]; -// }, - }); - - input.ac.on('query', function() { - Y.one("#prod_comp_throbber").removeClass('bz_default_hidden'); }); - input.ac.after('results', function() { - Y.one("#prod_comp_throbber").addClass('bz_default_hidden'); - }); - - input.ac.on('select', function (itemNode, result) { - var url = "enter_bug.cgi?product=" + encodeURIComponent(result.component) + - "&component=" + encodeURIComponent(result.product); - Y.log(url); - //autoComplete.dataReturnEvent.subscribe(function(type, args) { - // args[0].autoHighlight = args[2].length == 1; - //}); -// doBeforeLoadData: function(sQuery, oResponse, oPayload) { -// Y.one("#prod_comp_throbber").addClass('bz_default_hidden'); -// return true; -// } + input.on('focus', function (e) { + if (e.target.value && e.target.value.length > 3) { + dataSource.load(e.target.value); + } }); - -// autoComplete.textboxFocusEvent.subscribe(function () { -// var input = Y.one(field); -// if (input.value && input.value.length > 3) { -// sendQuery(input.value); -// } -// }); }); |