diff options
author | Byron Jones <bjones@mozilla.com> | 2012-05-30 06:06:55 +0200 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2012-05-30 06:06:55 +0200 |
commit | 61ab486097a60756792bc031c836f0e55393295c (patch) | |
tree | 98d674d833a08d7cedafde8c2349b091163f4459 /extensions/GuidedBugEntry/web | |
parent | ce8f837dcd1ccd23cd5f63f258efd257e3de70f3 (diff) | |
download | bugzilla-61ab486097a60756792bc031c836f0e55393295c.tar.gz bugzilla-61ab486097a60756792bc031c836f0e55393295c.tar.xz |
Bug 758141: add component searching to guided bug entry
Diffstat (limited to 'extensions/GuidedBugEntry/web')
-rw-r--r-- | extensions/GuidedBugEntry/web/js/guided.js | 78 | ||||
-rw-r--r-- | extensions/GuidedBugEntry/web/js/products.js | 28 | ||||
-rw-r--r-- | extensions/GuidedBugEntry/web/style/guided.css | 42 |
3 files changed, 72 insertions, 76 deletions
diff --git a/extensions/GuidedBugEntry/web/js/guided.js b/extensions/GuidedBugEntry/web/js/guided.js index 0812200ec..16f1d4952 100644 --- a/extensions/GuidedBugEntry/web/js/guided.js +++ b/extensions/GuidedBugEntry/web/js/guided.js @@ -1,27 +1,9 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1 +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the GuidedBugEntry Bugzilla Extension. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Byron Jones <glob@mozilla.com> - * - * ***** END LICENSE BLOCK ***** */ + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ // global @@ -67,7 +49,9 @@ var guided = { // update history if (History && !noSetHistory) { - History.navigate('h', newStep + "|" + product.getName()); + History.navigate('h', newStep + '|' + product.getName() + + (product.getPreselectedComponent() ? '|' + product.getPreselectedComponent() : '') + ); } }, @@ -91,8 +75,9 @@ var guided = { }, _onStateChange: function(state, noSetHistory) { - state = state.split("|"); + state = state.split('|'); product.setName(state[1] || ''); + product.setPreselectedComponent(state[2] || ''); guided.setStep(state[0], noSetHistory); }, @@ -111,8 +96,24 @@ var product = { details: false, _counter: 0, _loaded: '', + _preselectedComponent: '', - onInit: function() { }, + onInit: function() { + // BMO only + if (YAHOO.bugzilla.prodCompSearch.autoComplete) { + // show a throbber while searching for products + var autoComplete = YAHOO.bugzilla.prodCompSearch.autoComplete; + var orig_generateRequest = autoComplete.generateRequest; + autoComplete.generateRequest = function(sQuery) { + Dom.removeClass('prod_comp_throbber', 'hidden'); + return orig_generateRequest(sQuery); + }; + autoComplete.doBeforeLoadData = function(sQuery, oResponse, oPayload) { + Dom.addClass('prod_comp_throbber', 'hidden'); + return true; + }; + } + }, onShow: function() { Dom.removeClass('advanced', 'hidden'); @@ -129,6 +130,14 @@ var product = { return Dom.get('product').value; }, + getPreselectedComponent: function() { + return this._preselectedComponent; + }, + + setPreselectedComponent: function(value) { + this._preselectedComponent = value; + }, + _getNameAndRelated: function() { var result = []; @@ -635,7 +644,7 @@ var bugForm = { var elComponent = Dom.get('component'); if (products[productName] && products[productName].noComponentSelection) { - elComponent.value = products[productName].defaultComponent; + elComponent.value = products[productName].defaultComponent; bugForm._mandatoryFields = [ 'short_desc', 'version_select' ]; } else { @@ -643,9 +652,15 @@ var bugForm = { bugForm._mandatoryFields = [ 'short_desc', 'component_select', 'version_select' ]; // check for the default component - var defaultRegex = products[productName] && products[productName].defaultComponent - ? new RegExp('^' + products[productName].defaultComponent + '$', 'i') - : new RegExp('General', 'i'); + var defaultRegex; + if (product.getPreselectedComponent()) { + defaultRegex = new RegExp('^' + quoteMeta(product.getPreselectedComponent()) + '$', 'i') + } else if(products[productName] && products[productName].defaultComponent) { + defaultRegex = new RegExp('^' + quoteMeta(products[productName].defaultComponent) + '$', 'i') + } else { + defaultRegex = new RegExp('General', 'i'); + } + var preselectedComponent = false; for (var i = 0, n = product.details.components.length; i < n; i++) { var component = product.details.components[i]; @@ -899,3 +914,6 @@ var bugForm = { } } +function quoteMeta(value) { + return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); +} diff --git a/extensions/GuidedBugEntry/web/js/products.js b/extensions/GuidedBugEntry/web/js/products.js index 35799b74f..de6dfa330 100644 --- a/extensions/GuidedBugEntry/web/js/products.js +++ b/extensions/GuidedBugEntry/web/js/products.js @@ -1,27 +1,9 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1 +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the GuidedBugEntry Bugzilla Extension. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Byron Jones <glob@mozilla.com> - * - * ***** END LICENSE BLOCK ***** */ + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ /* Product-specifc configuration for guided bug entry * diff --git a/extensions/GuidedBugEntry/web/style/guided.css b/extensions/GuidedBugEntry/web/style/guided.css index b0c766d11..55550933f 100644 --- a/extensions/GuidedBugEntry/web/style/guided.css +++ b/extensions/GuidedBugEntry/web/style/guided.css @@ -1,27 +1,9 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1 +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the GuidedBugEntry Bugzilla Extension. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Byron Jones <glob@mozilla.com> - * - * ***** END LICENSE BLOCK ***** */ + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ /* global */ @@ -99,6 +81,20 @@ text-align: right; } +#prod_comp_search_main { + width: 400px; +} + +#prod_comp_search_label { + margin-bottom: 1px; +} + +#prod_comp_search_main li.yui-ac-highlight a { + text-decoration: none; + color: #FFFFFF; + display: block; +} + #products { width: 600px; } |