Bugzilla – Attachment 90252 Details for
Bug 14242
Use ISBN-field to fill out purchase suggestions using Google Books API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14242: (follow-up) Change the icon to words
Bug-14242-follow-up-Change-the-icon-to-words.patch (text/plain), 9.17 KB, created by
Maryse Simard
on 2019-05-31 19:37:13 UTC
(
hide
)
Description:
Bug 14242: (follow-up) Change the icon to words
Filename:
MIME Type:
Creator:
Maryse Simard
Created:
2019-05-31 19:37:13 UTC
Size:
9.17 KB
patch
obsolete
>From eaa95651a54c6bfd7641a5acfae3e5a439ef5ca6 Mon Sep 17 00:00:00 2001 >From: Chris Cormack <chrisc@catalyst.net.nz> >Date: Wed, 5 Oct 2016 20:58:26 +0000 >Subject: [PATCH] Bug 14242: (follow-up) Change the icon to words > >Fix a bug that meant it would search on empty ISBN > >To test >1. Fill in a valid ISBN (Book data is correctly loaded) >2. Clear the ISBN from the field (Book data is correctly removed) >3. Tab away from the empty ISBN field: Data is loaded for a title > "ISBN 0-9690745-2-2" >4. Apply patch >5. Repeat 1,2 and 3 notice a search is no longer done > >Signed-off-by: Marc <veron@veron.ch> >Signed-off-by: Maryse Simard <maryse.simard@inlibro.com> >--- > koha-tmpl/opac-tmpl/bootstrap/js/autofill.js | 156 +++++++++++++-------------- > 1 file changed, 78 insertions(+), 78 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/autofill.js b/koha-tmpl/opac-tmpl/bootstrap/js/autofill.js >index f6c487a..171cc93 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/autofill.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/autofill.js >@@ -27,8 +27,8 @@ > > /* decorate element as autofiller */ > var $inputgroup = $('<div class="input-prepend">'); >- self.$undo = $('<span class="add-on" style="display:none;cursor:pointer;">undo</span>'); >- self.$fillbtn = $('<span class="add-on"><i class="icon-edit" style="cursor:pointer;"></i></span>'); >+ self.$undo = $('<span class="add-on" style="display:none;cursor:pointer;">Undo</span>'); >+ self.$fillbtn = $('<span class="add-on" style="cursor:pointer;"> Search Google Books </span>'); > self.$error = $('<span class="add-on" style="display:none;"></span>'); > self.$elm.wrap($inputgroup); > self.$elm.after(self.$error); >@@ -63,87 +63,87 @@ > self.$error.hide(); > /* give user some feedback that the request is in progress */ > self.$fillbtn.fadeOut(1000).fadeIn(1000); >- >- var gAPI = 'https://www.googleapis.com/books/v1/volumes?q='; >- if(self.type) >- gAPI += self.type + ':'; >- gAPI += self.$elm.val(); >- gAPI += '&maxResults=1'; >- >- $.getJSON(gAPI, function (response) { >- if(response.totalItems == 0) { >- self.$error.html('Sorry, nothing found.'); >- self.$error.show(); >- return; >- } >- >- var undos = 0; >- var item = response.items[0]; >- for(var key in self.fields) { >- var filled = false; >- var value = eval('item.'+key); >- var field = self.fields[key]; >- >- /* field handled by caller */ >- if('handle' in field) { >- if(typeof field.handle === 'function') >- field.handle(field.$target, value); >- >- continue; /* next please */ >+ if ( self.$elm.val()) { >+ var gAPI = 'https://www.googleapis.com/books/v1/volumes?q='; >+ if(self.type) >+ gAPI += self.type + ':'; >+ gAPI += self.$elm.val(); >+ gAPI += '&maxResults=1'; >+ $.getJSON(gAPI, function (response) { >+ if(response.totalItems == 0) { >+ self.$error.html('Sorry, nothing found.'); >+ self.$error.show(); >+ return; > } > >- /* wouldn't know what to do with result unless we have a >- * target */ >- if( ! field.$target ) >- continue; >- >- /* handle differently depending on datatype */ >- switch(typeString(value)) { >- case 'array': >- switch(field.$target.prop('nodeName').toUpperCase()) { >- case 'TEXTAREA': >- undos++; >- field.$target.bind('autofill-undo', field.$target.text(), function(e){$(this).text(e.data);}); >- field.$target.text(value.join(', ')); >- break; >- case 'INPUT': >- default: >- undos++; >- field.$target.bind('autofill-undo', field.$target.val(), function(e){$(this).val(e.data);}); >- field.$target.val(value.join(', ')); >- break; >- } >- break; >- default: >- switch(field.$target.prop('nodeName').toUpperCase()) { >- case 'TEXTAREA': >- undos++; >- field.$target.bind('autofill-undo', field.$target.text(), function(e){$(this).text(e.data);}); >- field.$target.text(value); >- break; >- case 'SELECT': >- case 'INPUT': >- default: >- undos++; >- field.$target.bind('autofill-undo', field.$target.val(), function(e){$(this).val(e.data);}); >- field.$target.val(value); >- break; >- } >+ var undos = 0; >+ var item = response.items[0]; >+ for(var key in self.fields) { >+ var filled = false; >+ var value = eval('item.'+key); >+ var field = self.fields[key]; >+ >+ /* field handled by caller */ >+ if('handle' in field) { >+ if(typeof field.handle === 'function') >+ field.handle(field.$target, value); >+ >+ continue; /* next please */ >+ } >+ >+ /* wouldn't know what to do with result unless we have a >+ * target */ >+ if( ! field.$target ) >+ continue; >+ >+ /* handle differently depending on datatype */ >+ switch(typeString(value)) { >+ case 'array': >+ switch(field.$target.prop('nodeName').toUpperCase()) { >+ case 'TEXTAREA': >+ undos++; >+ field.$target.bind('autofill-undo', field.$target.text(), function(e){$(this).text(e.data);}); >+ field.$target.text(value.join(', ')); >+ break; >+ case 'INPUT': >+ default: >+ undos++; >+ field.$target.bind('autofill-undo', field.$target.val(), function(e){$(this).val(e.data);}); >+ field.$target.val(value.join(', ')); >+ break; >+ } >+ break; >+ default: >+ switch(field.$target.prop('nodeName').toUpperCase()) { >+ case 'TEXTAREA': >+ undos++; >+ field.$target.bind('autofill-undo', field.$target.text(), function(e){$(this).text(e.data);}); >+ field.$target.text(value); >+ break; >+ case 'SELECT': >+ case 'INPUT': >+ default: >+ undos++; >+ field.$target.bind('autofill-undo', field.$target.val(), function(e){$(this).val(e.data);}); >+ field.$target.val(value); >+ break; >+ } >+ } >+ >+ switch(field.effect) { >+ case 'flash': >+ field.$target.fadeOut(500).fadeIn(500); >+ break; >+ } > } > >- switch(field.effect) { >- case 'flash': >- field.$target.fadeOut(500).fadeIn(500); >- break; >- } >- } >- >- if(undos > 0) >- self.$undo.show(); >+ if(undos > 0) >+ self.$undo.show(); > >- }); >- }); >- }; >+ }); >+ } >+ }); >+ }; > > /* > * @fields object: Google Books API item propreties map for >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14242
:
42002
|
55949
|
56061
|
56062
|
56070
|
56071
|
56072
|
56073
|
56074
|
56075
|
84760
|
84761
|
84762
|
84763
|
84764
|
84840
|
85031
|
85032
|
85033
|
85034
|
85035
|
89643
|
89662
|
90157
|
90158
|
90159
|
90160
|
90161
|
90162
|
90250
|
90251
|
90252
|
90253
|
90254
|
90255
|
103527
|
103528
|
103529
|
103530
|
103531
|
103532
|
103533
|
108695
|
108696
|
108697
|
108698
|
108699
|
108700
|
108701
|
110141
|
110142
|
110143
|
110144
|
110145
|
110146
|
110147
|
110148
|
110493
|
110494
|
110495
|
110496
|
110497
|
110498
|
110499
|
110500
|
110501
|
110990
|
112597
|
112598
|
112599
|
112600
|
112601
|
112602
|
112603
|
112604
|
112605
|
112606
|
112607
|
113162
|
113163
|
113164
|
113165
|
113166
|
113167
|
116620
|
116712
|
116968
|
116989
|
125380
|
125381
|
125382
|
131219
|
131220
|
131221
|
131222
|
133985
|
133986
|
133987
|
133988
|
134273
|
134274
|
134275
|
134276
|
134277
|
134278