From 2a47aa4c865d7cf663d7e1dbc6f80cb5efdc6d2e Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 8 Mar 2013 12:16:19 -0500 Subject: [PATCH] Bug 9773 - Replace YUI AJAX calls in cataloging plugins with jQuery Several cataloging plugins make some simple AJAX GET calls via the YUI AJAX feature. This code can be easily converted to jQuery. To test, link each plugin to the relelvant field by editing your MARC stucture. Confirm that functionality is unchanged. For callnumber.pl and callnumber-KU.pl, test by linking to 952o. callnumber.pl is triggered on blur of (when you focus on and click away from) the 952o entry field. callnumber-KU.pl is triggered by clicking the "..." link. stocknumberam123.pl should be linked to 952i. If your data doesn't already have information stored for inventory number, modify at least one record to add one. The plugin is triggered on blur of the 952i field. It should increment the highest value inventory number stored in your system. unimarc_field_010.pl is UNIMARC-specific, so I'm guessing about its functionality. I tested it by linking the plugin to MARC21 field 020a. The plugin is triggered on blur of the affected field (020a in my test). You can confirm that the plugin returns valid data by using a tool like Firebug to view the XHR response. Or if you're not using UNIMARC you can hack the plugin to update a different field instead (line 57, /^tag_210_subfield_c/ ). I tried "245_subfield_c" instead of "210c_subfield_c." Nonsensical, but useful for testing. Signed-off-by: Mirko Tietgen Tried the 3 MARC21 plugins. Did not try the Unimarc one, but it's exactly the same code change. Signed-off-by: Jonathan Druart --- cataloguing/value_builder/callnumber-KU.pl | 13 +++++-------- cataloguing/value_builder/callnumber.pl | 13 +++++-------- cataloguing/value_builder/stocknumberam123.pl | 13 +++++-------- cataloguing/value_builder/unimarc_field_010.pl | 11 ++++------- 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/cataloguing/value_builder/callnumber-KU.pl b/cataloguing/value_builder/callnumber-KU.pl index 201f9c8..0d1b539 100755 --- a/cataloguing/value_builder/callnumber-KU.pl +++ b/cataloguing/value_builder/callnumber-KU.pl @@ -57,14 +57,11 @@ sub plugin_javascript { function Clic$field_number() { var code = document.getElementById('$field_number'); var url = '../cataloguing/plugin_launcher.pl?plugin_name=callnumber-KU.pl&code=' + code.value; - var blurcallbackcallnumber = { - success: function(o) { - var field = document.getElementById('$field_number'); - field.value = o.responseText; - return 1; - } - } - var transaction = YAHOO.util.Connect.asyncRequest('GET',url, blurcallbackcallnumber, null); + var req = \$.get(url); + req.done(function(resp){ + code.value = resp; + return 1; + }); return 1; } diff --git a/cataloguing/value_builder/callnumber.pl b/cataloguing/value_builder/callnumber.pl index 64507f2..56ef174 100755 --- a/cataloguing/value_builder/callnumber.pl +++ b/cataloguing/value_builder/callnumber.pl @@ -50,14 +50,11 @@ sub plugin_javascript { function Blur$field_number() { var code = document.getElementById('$field_number'); var url = '../cataloguing/plugin_launcher.pl?plugin_name=callnumber.pl&code=' + code.value; - var blurcallbackcallnumber = { - success: function(o) { - var field = document.getElementById('$field_number'); - field.value = o.responseText; - return 1; - } - } - var transaction = YAHOO.util.Connect.asyncRequest('GET',url, blurcallbackcallnumber, null); + var req = \$.get(url); + req.done(function(resp){ + code.value = resp; + return 1; + }); return 1; } diff --git a/cataloguing/value_builder/stocknumberam123.pl b/cataloguing/value_builder/stocknumberam123.pl index ab88f61..6357822 100755 --- a/cataloguing/value_builder/stocknumberam123.pl +++ b/cataloguing/value_builder/stocknumberam123.pl @@ -51,14 +51,11 @@ sub plugin_javascript { function Blur$field_number() { var code = document.getElementById('$field_number'); var url = '../cataloguing/plugin_launcher.pl?plugin_name=stocknumberam123.pl&code=' + code.value; - var blurcallbackstocknumber = { - success: function(o) { - var field = document.getElementById('$field_number'); - field.value = o.responseText; - return 1; - } - } - var transaction = YAHOO.util.Connect.asyncRequest('GET',url, blurcallbackstocknumber, null); + var req = \$.get(url); + req.done(function(resp){ + code.value = resp; + return 1; + }); return 1; } diff --git a/cataloguing/value_builder/unimarc_field_010.pl b/cataloguing/value_builder/unimarc_field_010.pl index bf06775..b48c9ae 100755 --- a/cataloguing/value_builder/unimarc_field_010.pl +++ b/cataloguing/value_builder/unimarc_field_010.pl @@ -49,20 +49,17 @@ sub plugin_javascript { function Blur$field_number() { var isbn = document.getElementById('$field_number'); var url = '../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_010.pl&isbn=' + isbn.value; - var blurcallback010 = - { - success: function(o){ + var req = \$.get(url); + req.done(function(resp){ var elems = document.getElementsByTagName('input'); for( i = 0 ; elems[i] ; i++ ) { if(elems[i].id.match(/^tag_210_subfield_c/)) { - elems[i].value = o.responseText; + elems[i].value = resp; return 1; } } - } - } - var transaction = YAHOO.util.Connect.asyncRequest('GET',url, blurcallback010, null); + }); return 1; } -- 1.7.10.4