Add some style to the OpenLibrary read links
authorDan Scott <dan@coffeecode.net>
Thu, 2 Jun 2011 02:18:42 +0000 (22:18 -0400)
committerDan Scott <dan@coffeecode.net>
Thu, 2 Jun 2011 02:18:42 +0000 (22:18 -0400)
George Oates provided an OpenLibrary GIF to use for the
links, and we can drop the links right into the block of
white space between copy counts and bibliographic info.

Also a bit of refactoring to reduce code duplication.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Open-ILS/web/opac/images/openlibrary.gif [new file with mode: 0644]
Open-ILS/web/opac/skin/default/js/result_common.js
Open-ILS/web/opac/skin/default/xml/result/result_table.xml

diff --git a/Open-ILS/web/opac/images/openlibrary.gif b/Open-ILS/web/opac/images/openlibrary.gif
new file mode 100644 (file)
index 0000000..9ac053d
Binary files /dev/null and b/Open-ILS/web/opac/images/openlibrary.gif differ
index 93cc3bb..809579f 100644 (file)
@@ -716,51 +716,50 @@ function renderOpenLibraryLinks(response) {
         });
 
         /* Now populate the results page with our ebook goodness*/
-        var ol_span = $n(document.documentElement, 'openLibraryLink-' + isbn);
-
-        dojo.removeClass(ol_span, 'hide_me');
         /* Go for the jugular - exact match with full access */
         if (ol_ebooks[isbn]['exact_full']) {
-            var ol_a_span = dojo.create('a', {
-                    "href": ol_ebooks[isbn]['exact_full'],
-                    "class": "classic_link"
-                }, ol_span
+            createOpenLibraryLink(
+                isbn, ol_ebooks[isbn]['exact_full'], 'Read online'
             );
-            ol_a_span.appendChild(dojo.doc.createTextNode('Read online'));
-            dojo.removeClass(ol_span, 'hide_me');
             continue;
         }
 
         /* Fall back to slightly less palatable options */
         else if (ol_ebooks[isbn]['exact_lendable']) {
-            var ol_a_span = dojo.create('a', {
-                    "href": ol_ebooks[isbn]['exact_lendable'],
-                    "class": "classic_link"
-                }, ol_span
+            createOpenLibraryLink(
+                isbn, ol_ebooks[isbn]['exact_lendable'], 'Borrow online'
             );
-            ol_a_span.appendChild(dojo.doc.createTextNode('Borrow online'));
         }
 
         if (ol_ebooks[isbn]['similar_full']) {
-            var ol_a_span = dojo.create('a', {
-                    "href": ol_ebooks[isbn]['similar_full'],
-                    "class": "classic_link"
-                }, ol_span
+            createOpenLibraryLink(
+                isbn, ol_ebooks[isbn]['similar_full'], 'Read similar online'
             );
-            ol_a_span.appendChild(dojo.doc.createTextNode('Read similar online'));
         } else if (ol_ebooks[isbn]['similar_lendable']) {
-            var ol_a_span = dojo.create('a', {
-                    "href": ol_ebooks[isbn]['similar_lendable'],
-                    "class": "classic_link"
-                }, ol_span
+            createOpenLibraryLink(
+                isbn, ol_ebooks[isbn]['similar_full'], 'Borrow similar online'
             );
-            ol_a_span.appendChild(dojo.doc.createTextNode('Borrow similar online'));
         }
-
-        dojo.removeClass(ol_span, 'hide_me');
     }
 }
 
+function createOpenLibraryLink(isbn, url, text) {
+    var ol_span = $n(document.documentElement, 'openLibraryLink-' + isbn);
+
+    var ol_a_span = dojo.create('a', {
+            "href": url,
+            "class": "classic_link"
+        }, ol_span
+    );
+    dojo.create('img', {
+            "src": "/opac/images/openlibrary.gif"
+        }, ol_a_span
+    );
+    dojo.create('br', null, ol_a_span);
+    ol_a_span.appendChild(dojo.doc.createTextNode(text));
+    dojo.removeClass(ol_span, 'hide_me');
+}
+
 function fetchGoogleBooksLink () {
     if (isbnList.length > 0 && googleBooksLink) {
         var scriptElement = document.createElement("script");
index e45a9c4..0249cba 100644 (file)
@@ -44,6 +44,8 @@
                                     </a>
                                 </td>
 
+                                <!-- Empty span used for creating OpenLibrary links -->
+                                <td rowspan='4' name="openLibraryLink" style="text-align: center; vertical-align: middle; width: 15em;" class="hide_me"></td>
                                 <!-- Copy this td for each copy count appended -->
                                 <td  rowspan='4' nowrap='nowrap' name="copy_count_cell" class='copy_count_cell'> 
                                 </td>
@@ -55,8 +57,6 @@
                                     <a title="&result.table.author;" name='item_author' class='search_link'> 
                                         <!-- Author goes here -->
                                     </a>
-                                    <!-- Empty span used for creating OpenLibrary links -->
-                                    <span name="openLibraryLink" style="float: right; margin-right: 4em;" class="hide_me"></span>
                                     <div>
                                     <span name='result_table_extra_span' class='hide_me'>
                                         <span name='result_table_pub_box' style='padding-left: 10px;'>