From: Dan Scott Date: Fri, 3 Jun 2011 18:48:30 +0000 (-0400) Subject: Refactor the "show copy notes button" functionality X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bf9017e16fb6d0e7568fc3b6a713363008a60f37;p=evergreen%2Fpines.git Refactor the "show copy notes button" functionality Collapse the duplicated code for showing / hiding the "show copy notes button" into a single method. Might make maintenance a bit easier some day. Signed-off-by: Dan Scott Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.js b/Open-ILS/xul/staff_client/server/cat/copy_editor.js index 3967b55f8f..44bfaaa625 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -1,4 +1,4 @@ -// vim:noet:sw=4:ts=4 +// vim:et:sw=4:ts=4 var g = {}; g.map_acn = {}; @@ -168,14 +168,7 @@ function my_init() { try { g.copies = xulG.copies; g.original_copies = js2JSON( g.copies ); - if (g.copies.length > 0 && g.copies[0].id() < 0) { - document.getElementById('copy_notes').setAttribute('hidden','true'); - $('save').setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.create_copies')); - $('save').setAttribute('accesskey', $('catStrings').getString('staff.cat.copy_editor.create_copies.accesskey')); - } - if (g.copies.length != 1) { - document.getElementById('copy_notes').setAttribute('hidden','true'); - } + g.show_copy_notes_button(); for (var i = 0; i < g.applied_templates.length; i++) { g._apply_template( g.applied_templates[i], false); } @@ -193,14 +186,7 @@ function my_init() { g.changed[ 'volume_copy_creator.'+id ] = { 'type' : 'volume_copy_creator', 'field' : id, 'value' : v }; } } else { - if (g.copies.length > 0 && g.copies[0].id() < 0) { - document.getElementById('copy_notes').setAttribute('hidden','true'); - $('save').setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.create_copies')); - $('save').setAttribute('accesskey', $('catStrings').getString('staff.cat.copy_editor.create_copies.accesskey')); - } - if (g.copies.length != 1) { - document.getElementById('copy_notes').setAttribute('hidden','true'); - } + g.show_copy_notes_button(); } } catch(E) { @@ -211,6 +197,19 @@ function my_init() { } /******************************************************************************************************/ +/* Show copy notes button */ +g.show_copy_notes_button = function() { + if (g.copies.length > 0 && g.copies[0].id() < 0) { + document.getElementById('copy_notes').setAttribute('hidden','true'); + $('save').setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.create_copies')); + $('save').setAttribute('accesskey', $('catStrings').getString('staff.cat.copy_editor.create_copies.accesskey')); + } + if (g.copies.length != 1) { + document.getElementById('copy_notes').setAttribute('hidden','true'); + } +} + +/******************************************************************************************************/ /* Retrieve Templates */ g.retrieve_templates = function() {