adding basic preference grabbing and updating example for myopac,
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 16 Nov 2005 18:12:27 +0000 (18:12 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 16 Nov 2005 18:12:27 +0000 (18:12 +0000)
(though I'm not actually using the value right now)

added a 'loading' deck to swap out for long searches

git-svn-id: svn://svn.open-ils.org/ILS/trunk@2044 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/skin/default/css/layout.css
Open-ILS/web/opac/skin/default/js/mresult.js
Open-ILS/web/opac/skin/default/js/myopac.js
Open-ILS/web/opac/skin/default/js/result_common.js
Open-ILS/web/opac/skin/default/xml/altcanvas.xml
Open-ILS/web/opac/skin/default/xml/login.xml
Open-ILS/web/opac/skin/default/xml/myopac_prefs.xml

index b17a0c4..17b06cd 100644 (file)
@@ -331,6 +331,13 @@ function updateUserSetting(setting, value, user) {
        return req.result();
 }
 
+function commitUserPrefs() {
+       var req = new Request( 
+               UPDATE_USER_PREFS, G.user.session, G.user.prefs );
+       req.send(true);
+       return req.result();
+}
+
 function grabSkinFromURL() {
        var path = findBasePath();
        path = path.replace("/xml/", "");
index de00859..9b50e17 100644 (file)
@@ -8,6 +8,14 @@ body { margin: 6px; }
 
 table { border-collapse: collapse; }
 
+/* generic CSS for a table with data */
+.data_grid { font-weight: 500; }
+.data_grid thead tr { background: #CCFFFF; color: #000000; border: 1px solid #808080; }
+.data_grid thead td { border-bottom: 1px solid #808080; }
+.data_grid tbody td { border: 1px solid #E0E0E0; padding: 5px; }
+
+
+
 .encircled { border: 1px solid black; }
 
 .light_border { border: 1px solid #E0E0E0; }
index cdd07f1..af117ac 100644 (file)
@@ -14,6 +14,9 @@ function mresultUnload() { removeChildren(table); table = null;}
 
 function mresultDoSearch() {
 
+       if(getOffset() == 0)
+               setTimeout("swapCanvas($('loading_alt'))",100);
+
        table = G.ui.result.main_table;
 
        while( table.parentNode.rows.length <= (getDisplayCount() + 1) )  /* add an extra row so IE and safari won't complain */
index 2ee000a..31cbf1c 100644 (file)
@@ -332,8 +332,36 @@ function myOPACShowTransactions(r) {
        }
 }
 
+function myOPACSavePrefs() {
+       G.user.prefs['opac.hits_per_page'] = 
+               $('prefs_hits_per').options[$('prefs_hits_per').selectedIndex].value;
+       if(commitUserPrefs())
+               alert($('prefs_update_success').innerHTML);
+       else alert($('prefs_update_failure').innerHTML);
+}
+
 
 function myOPACShowPrefs() {
+       grabUserPrefs();
+       myOPACShowHitsPer();
+       hideMe($('myopac_prefs_loading'));
+       unHideMe($('myopac_prefs_row'));
+}
+
+function myOPACShowHitsPer() {
+       var hits = 10;
+       if(G.user.prefs['opac.hits_per_page'])
+               hits = G.user.prefs['opac.hits_per_page'];
+
+       var hitsSel = $('prefs_hits_per');
+
+       for( var o in hitsSel.options ) {
+               var opt = hitsSel.options[o];
+               if( hits == opt.value ) {
+                       opt.selected = true;
+                       hitsSel.selectedIndex = o;
+               }
+       }
 }
 
 var userShown = false;
index 6eee65c..96c5b3d 100644 (file)
@@ -75,6 +75,8 @@ function resultPaginate() {
 /* display the record info in the record display table 'pos' is the 
                zero based position the record should have in the display table */
 function resultDisplayRecord(rec, pos, is_mr) {
+       showCanvas();
+       try{killPinwheel();}catch(E){}
 
        if(rec == null) rec = new mvr(); /* so the page won't die if there was an error */
        recordsHandled++;
@@ -158,6 +160,7 @@ function resultDisplayRecord(rec, pos, is_mr) {
        runEvt("result", "recordDrawn", rec.doc_id(), title_link);
 
        if(resultPageIsDone())  {
+               //showCanvas();
                /* hide the 'now loading...' message */
                /*
                hideMe(G.ui.common.loading);
index 85e2784..411c59e 100644 (file)
        <!-- ============================================================================= -->
        <!-- Register the alternate canvases  -->
        <script language='javascript'>
-               config.ids.altcanvas.login              = config.ids.login.box;
-               config.ids.altcanvas.org_tree    = config.ids.common.org_container;
+               config.ids.altcanvas.login                      = config.ids.login.box;
+               config.ids.altcanvas.org_tree           = config.ids.common.org_container;
                config.ids.altcanvas.holds                      = 'holds_box';
+               config.ids.altcanvas.loading            = 'loading_alt';
        </script>
 
        <xi:include href='holds.xml'/>
 
+       <div id='loading_alt' class='hide_me non_canvas' style='margin-top: 6px;'>
+               <div style='margin-top: 30px; text-align: left; font-weight: 700;' class='color_3'>
+                       <span > Loading </span>
+                       <span id='loading_alt_span'> </span>
+                       <script language='javascript'>
+                               var __id;
+                               var __count = 300;
+                               var __dot;
+                               var __idx = 0;
+                               var __slashes = [ '-', '\\\\', '|', '/' ];
+                               function __loading() { 
+                                       if( __count-- == 0 ) return;
+                                       __dot = __slashes[__idx++];
+                                       if(__idx == 4) __idx = 0;
+                                       __id = setTimeout(
+                                               "appendClear($('loading_alt_span'), text('"+__dot+"'));__loading();", 100);
+                               }
+                               __loading();
+                               function __killPinwheel(){ __count = 0; }
+                       </script>
+               </div>
+       </div>
+
 </div>
index 3a8dbab..339c95a 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version='1.0'?>
 
-<div id='login_box' class='hide_me color_1 non_canvas' style='margin-top: 6px;'>
+<div id='login_box' class='hide_me non_canvas' style='margin-top: 6px;'>
 
        <script language='javascript'>
                config.ids.login = {};
@@ -12,7 +12,7 @@
                config.ids.login.cancel         = "login_cancel_button";
        </script>
 
-       <div class='login_text'>
+       <div class='login_text color_1'>
                <span> Login with your username and password. </span>
        </div>
 
index 98090b9..b6cdc17 100644 (file)
@@ -2,25 +2,55 @@
 
 <div id='myopac_prefs_div' xmlns:xi="http://www.w3.org/2001/XInclude" >
 
-       <table width='100%' class='light_border myopac_table'>
+       <table width='100%' class='data_grid'>
 
                <br/>
-               <thead class='color_3'>
-                       <tr><td style='background: none;' align='center' colspan='4'><b>Preferences</b></td></tr>
+               <thead>
                        <tr>
-                               <td width=''>More To Come...</td>
+                               <td colspan='2' align='center'>
+                                       <b>Preferences</b>
+                               </td>
                        </tr>
+                       <!--
+                       <tr>
+                               <td >More To Come...</td>
+                       </tr>
+                       -->
                </thead>
 
                <tbody id='myopac_prefs_tbody'>
-                       <!--
                        <tr id='myopac_prefs_loading'><td>Loading...</td></tr>
-                       -->
                        <tr id='myopac_prefs_row' class='light_border hide_me'>
+                               <td width='50%'>Search hits per page</td>
+                               <td>
+                                       <select id='prefs_hits_per'>
+                                               <option>5</option>
+                                               <option>10</option>
+                                               <option>15</option>
+                                               <option>20</option>
+                                               <option>25</option>
+                                               <option>50</option>
+                                       </select>
+                               </td>
+                       </tr>
+
+                       <tr>
+                               <td align='middle' colspan='2'>
+                                       <button onclick='myOPACSavePrefs();' 
+                                               id='myopac_prefs_submit'>Save Changes</button>
+                               </td>
                        </tr>
+
+                       <tr>
+                               <td colspan='2' align='center'><br/><b> * More To Come...</b></td>
+                       </tr>
+
                </tbody>
        </table>
 
+       <div class='hide_me' id='prefs_update_success'>Preferences successfully updated</div>
+       <div class='hide_me' id='prefs_update_failure'>Preferences update failed!</div>
+
 </div>