From e189d1fdef2c7fb2e9d29d697f4eda8f7916af87 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Tue, 9 Jun 2015 10:10:04 -0400 Subject: [PATCH] LP#1154656 MARC Expert Search "Add Rows" adds duplicate row This patch changes the behavior of the "Add Search Row" link (JavaScript function from simple.js "addExpertRow()") so that we are always cloning the initial "empty" row instead of potentially cloning a row -- by way of cloneNode() -- with user input in place, and causing duplicate search rows. Signed-off-by: Michael Peters --- Open-ILS/src/templates/opac/css/style.css.tt2 | 8 +++++++- Open-ILS/web/js/ui/default/opac/simple.js | 27 +++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/templates/opac/css/style.css.tt2 b/Open-ILS/src/templates/opac/css/style.css.tt2 index 56cbef8e9c..cafccb64dc 100644 --- a/Open-ILS/src/templates/opac/css/style.css.tt2 +++ b/Open-ILS/src/templates/opac/css/style.css.tt2 @@ -2101,4 +2101,10 @@ See also http://webaim.org/techniques/css/invisiblecontent/ overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; -} +} + +/* Make added rows in Expert Search have bold labels like the initial row */ +label[for*=expert_] +{ + font-weight: bold; +} diff --git a/Open-ILS/web/js/ui/default/opac/simple.js b/Open-ILS/web/js/ui/default/opac/simple.js index b4915862a2..7fa20cb647 100644 --- a/Open-ILS/web/js/ui/default/opac/simple.js +++ b/Open-ILS/web/js/ui/default/opac/simple.js @@ -26,18 +26,33 @@ function addSearchRow() { _search_row_template.cloneNode(true), $("adv_global_addrow") ); + + $("adv_global_input_table").rows[$("adv_global_input_table").rows.length - 2].getElementsByTagName("input")[0].value = ""; } -function addExpertRow() { - if (!_expert_row_template) { - t = $("adv_expert_row").cloneNode(true); - t.id = null; - _expert_row_template = t; - } +(function($){ +var _search_row_template, _expert_row_template, t; +var _el_adv_global_row = $("adv_global_row"), _el_adv_expert_row = $("adv_expert_row"); +if (_el_adv_global_row) { + t = _el_adv_global_row.cloneNode(true); + t.id = null; + _search_row_template = t; +} + +if (_el_adv_expert_row) { + t = _el_adv_expert_row.cloneNode(true); + t.id = null; + _expert_row_template = t; +} +function addExpertRow() { $("adv_expert_rows_here").appendChild( _expert_row_template.cloneNode(true) ); } + +window.addSearchRow = addSearchRow; +window.addExpertRow = addExpertRow; +})($); function killRowIfAtLeast(min, link) { var row = link.parentNode.parentNode; if (row.parentNode.getElementsByTagName("tr").length > min) -- 2.11.0