Start replacing jscalendar and DP_DateExtensions with Dojo
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 26 Jul 2008 05:14:11 +0000 (05:14 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 26 Jul 2008 05:14:11 +0000 (05:14 +0000)
  * Use dijit.DateTextBox for date picker in setting "suspend hold until" dates
  * Start using dojo.date.stamp.* and dojo.date.locale.* functions instead of DP_DateExtensions
    * Here, we replace all occurrences of Date.parseIso8601()
  * Remove ISO formatting hints as hold dates now use locales rather than being hardcoded

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

Open-ILS/web/opac/common/js/DP_DateExtensions.js
Open-ILS/web/opac/locale/en-US/opac.dtd
Open-ILS/web/opac/skin/default/js/holds.js
Open-ILS/web/opac/skin/default/js/myopac.js
Open-ILS/web/opac/skin/default/xml/body.xml
Open-ILS/web/opac/skin/default/xml/common/css_common.xml
Open-ILS/web/opac/skin/default/xml/common/holds.xml
Open-ILS/web/opac/skin/default/xml/common/js_common.xml
Open-ILS/web/opac/skin/default/xml/myopac/myopac_holds.xml

index fd602c6..db96365 100644 (file)
@@ -21,6 +21,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
 CHANGES: --------------------------------------------------------------------------------
 
+       2008-07-26 / dscott@laurentian.ca
+        - Comment out Date.parseIso8601 as we move to Dojo
+
     2007-02-02 / billserickson@gmail.com
      - chopped out some utility methods to trim file size
      - changed some formatting for visual ease
@@ -29,7 +32,7 @@ CHANGES: -----------------------------------------------------------------------
         comes accross 123456ms and not 123ms + 456 microseconds
 */
 
-
+/*
 Date.parseIso8601 = function(CurDate) {
 
                // Check the input parameters
@@ -91,6 +94,8 @@ Date.parseIso8601 = function(CurDate) {
 
 };
 
+*/
+
 
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 /* "Date" Object Prototype Extensions */
index ece075b..48017ff 100644 (file)
@@ -222,7 +222,6 @@ If an item has already been selected to fulfill the hold, it will not be suspend
 <!ENTITY opac.holds.freeze "Suspend this hold">
 <!ENTITY opac.holds.freeze.help "A suspended hold will retain its place in the queue, but will not be fulfilled until it has been activated.">
 <!ENTITY opac.holds.freeze.thaw_date "Automatically activate hold on:">
-<!ENTITY opac.holds.freeze.thaw_date.format "YYYY-MM-DD">
 
 <!--   ================================================================= 
        MyOPAC Preferences Page 
index 9b8dddc..b201d35 100644 (file)
@@ -142,13 +142,13 @@ function _holdsUpdateEditHold() {
         frozenbox.checked = true;
         unHideMe($('hold_frozen_thaw_row'));
         if(hold.thaw_date()) {
-            $('holds_frozen_thaw_input').value = hold.thaw_date();
+            dijit.byId('holds_frozen_thaw_input').setValue(hold.thaw_date());
         } else {
-            $('holds_frozen_thaw_input').value = '';
+            dijit.byId('holds_frozen_thaw_input').setValue('');
         }
     } else {
         frozenbox.checked = false;
-        $('holds_frozen_thaw_input').value = '';
+        dijit.byId('holds_frozen_thaw_input').setValue('');
         hideMe($('hold_frozen_thaw_row'));
     }
 }
@@ -715,7 +715,7 @@ function holdsBuildHoldFromWindow() {
     if($('holds_frozen_chkbox').checked) {
         hold.frozen('t');
         unHideMe($('hold_frozen_thaw_row'));
-        thawDate = $('holds_frozen_thaw_input').value;
+        thawDate = dojo.date.stamp.toISOString(dijit.byId('holds_frozen_thaw_input').getValue());
         if(thawDate) {
             thawDate = holdsVerifyThawDate(thawDate); 
             if(thawDate) 
@@ -831,25 +831,16 @@ function holdsUpdate(hold, user) {
        runEvt('common', 'holdUpdated');
 }
 
-
 /* verify that the thaw date is valid and after today */
 function holdsVerifyThawDate(dateString) {
-    thawDate = Date.parseIso8601(dateString);
-    if(thawDate && holdGreaterThanToday(dateString)) 
-        return thawDate.iso8601Format('YMD', false, false, true);
+    thawDate = dojo.date.stamp.fromISOString(dateString);
+    if(thawDate && (dojo.date.compare(thawDate) > 0))
+        return dojo.date.stamp.toISOString(thawDate);
     return null;
 }
 
-function holdGreaterThanToday(dateString) {
-    thawDate = Date.parseIso8601(dateString);
-    var today = new Date();
-    today = new Date(today.getFullYear(), today.getMonth(), today.getDate())
-    return thawDate > today;
-}
-
-
 function holdsVerifyThawDateUI(element) {
-    value = $(element).value;
+    value = dojo.date.stamp.toISOString(dijit.byId(element).getValue());
 
     if(!value) {
         removeCSSClass($(element), 'invalid_field');
index 21d0b2d..14c83e2 100644 (file)
@@ -348,8 +348,8 @@ function myOPACDrawHolds(r) {
             hideMe($n(row, 'myopac_hold_unfrozen_true'))
             unHideMe($n(row, 'myopac_hold_unfrozen_false'))
             if(h.thaw_date()) {
-                var d = Date.parseIso8601(h.thaw_date());
-                $n(row, 'myopac_holds_frozen_until').appendChild(text(d.iso8601Format('YMD')));
+                var d = dojo.date.stamp.fromISOString(h.thaw_date());
+                $n(row, 'myopac_holds_frozen_until').appendChild(text(dojo.date.locale.format(d, {.selector: 'date', fullYear: true})));
             }
         } else {
             unHideMe($n(row, 'myopac_hold_unfrozen_true'))
@@ -518,14 +518,14 @@ function _finesFormatNumber(num) {
 //function _trimTime(time) { if(!time) return ""; return time.replace(/\ .*/,""); }
 function _trimTime(time) { 
        if(!time) return ""; 
-    var d = Date.parseIso8601(time);
+    var d = dojo.date.stamp.fromISOString(time);
     if(!d) return ""; /* date parse failed */
     return d.iso8601Format('YMD');
 }
 
 function _trimSeconds(time) { 
     if(!time) return ""; 
-    var d = Date.parseIso8601(time);
+    var d = dojo.date.stamp.fromISOString(time);
     if(!d) return ""; /* date parse failed */
     return d.iso8601Format('YMDHM',null,true,true);
 }
@@ -761,7 +761,7 @@ function _myOPACSummaryShowUer(r) {
        fleshedUser = user;
        if(!user) return;
 
-    var expireDate = Date.parseIso8601(user.expire_date());
+    var expireDate = dojo.date.stamp.fromISOString(user.expire_date());
     if( expireDate < new Date() ) {
         appendClear($('myopac.expired.date'), expireDate.iso8601Format('YMD'));
         unHideMe($('myopac.expired.alert'));
@@ -1192,7 +1192,7 @@ function myOPACDrawNonCatCirc(r) {
        duration = parseInt(duration + '000');
 
        var dtf = circ.circ_time();
-    var start = Date.parseIso8601(circ.circ_time());
+    var start = dojo.date.stamp.fromISOString(circ.circ_time());
        var due = new Date(  start.getTime() + duration );
        appendClear($n(row, 'circ_time'), text(due.iso8601Format('YMDHM', null, true, true)));
 }
@@ -1431,17 +1431,10 @@ function myopacDrawHoldThawDateForm() {
     hideMe($('myopac_holds_main_table'));
     unHideMe($('myopac_holds_thaw_date_form'));
     $('myopac_holds_thaw_date_input').focus();
-    Calendar.setup({
-        inputField  : "myopac_holds_thaw_date_input",
-        ifFormat    : "%Y-%m-%d",
-        button      : "myopac_holds_thaw_date_img",
-        align       : "Tl",
-        singleClick : true
-    });
 }
 
 function myopacApplyThawDate() {
-    var dateString = $('myopac_holds_thaw_date_input').value;
+    var dateString = dojo.date.stamp.toISOString(dijit.byId('myopac_holds_thaw_date_input').getValue());
     if(dateString) {
         dateString = holdsVerifyThawDate(dateString);
         if(!dateString) return;
index e916df7..4e4b221 100644 (file)
@@ -1,7 +1,7 @@
 <!--
 <body onload='init();' style='height: 100%; border: 2px solid black;'>
 -->
-<body onload='init();'>
+<body class="tundra" onload='init();'>
        <table width='100%'>
                <tbody>
                        <tr>
index 17bd732..452a0a3 100644 (file)
@@ -1,4 +1,3 @@
-
 <!-- CSS shared across pages goes here --> 
 
 <link type='text/css' rel='stylesheet' href="<!--#echo var='OILS_SKIN_BASE'-->/default/css/layout.css"/>
@@ -17,3 +16,9 @@
        rel='search' title="Evergreen"
        href="http://<!--#echo var='SERVER_NAME'-->/opac/extras/opensearch/1.1/-/osd.xml" />
 
+<!-- enable Dojo date picker -->
+<style type="text/css">
+       @import '/js/dojo/dojo/resources/dojo.css';
+       @import '/js/dojo/dijit/themes/tundra/tundra.css';
+       @import '/js/dojo/dijit/themes/tundra/tundra_rtl.css';
+</style>
index fdd251c..b5899e7 100644 (file)
@@ -1,10 +1,4 @@
-<link rel="stylesheet" type="text/css"
-    href='<!--#echo var="OILS_JS_BASE"-->/jscalendar/calendar-brown.css' title="win2k-cold-1" />
-<script language='javascript' type='text/javascript' src='<!--#echo var="OILS_JS_BASE"-->/jscalendar/calendar.js'></script>
-<script language='javascript' type='text/javascript' src='<!--#echo var="OILS_JS_BASE"-->/jscalendar/lang/calendar-en.js'></script>
-<script language='javascript' type='text/javascript' src='<!--#echo var="OILS_JS_BASE"-->/jscalendar/calendar-setup.js'></script>
 <script language='javascript' type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/common/js/DP_DateExtensions.js'></script>
-
 <div>
        <div id='xulholds_box' class='hide_me canvas' style='margin-top: 6px;'>
                <center>
                         &opac.holds.freeze.thaw_date;
                     </td>
                     <td class='holds_cell'>
-                        <input size='10' maxlength='10' id='holds_frozen_thaw_input' />
-                        <button style='padding: 0px;' id='holds_frozen_thaw_date_button'>
-                            <img src='<!--#echo var="OILS_JS_BASE"-->/jscalendar/img.gif'
-                                style="cursor: pointer; border: 1px solid red; padding: 0px; margin: -3px;"
-                                title="Date selector"
-                                onmouseover="this.style.background='red';"
-                                onmouseout="this.style.background=''" />
-                        </button>
-                        &nbsp;(&opac.holds.freeze.thaw_date.format;)
-
-                        <script language='javascript' type="text/javascript">
-                            Calendar.setup({
-                                inputField  : "holds_frozen_thaw_input",
-                                ifFormat    : "%Y-%m-%d",
-                                button      : "holds_frozen_thaw_date_button",
-                                align       : "Tl", 
-                                singleClick : true
-                            });
-                        </script>
-
+                        <input dojoType="dijit.form.DateTextBox" size='10' maxlength='10' id='holds_frozen_thaw_input' />
                     </td>
                 </tr>
 
        <span id='holds_invalid_recipient' class='hide_me'>&common.hold.patron.invalid;</span>
 
 </div>
-
-
index d1c17ab..4e8a027 100644 (file)
                <!--#endif -->
 
        </script>
+
+    <!-- enable Dojo date picker -->
+    <script language='javascript' type="text/javascript">
+        var djConfig = {parseOnLoad: true, isDebug: true},
+            locale,
+            lang,
+            bidi;
+
+        djConfig.locale = '<!--#echo var="locale"-->';
+    </script>
+
+    <script type="text/javascript" src='/js/dojo/dojo/dojo.js'></script>
+
+    <script language="javascript" type="text/javascript">
+        dojo.require("dijit._Calendar");
+        dojo.require("dijit.form.DateTextBox");
+        dojo.require("dojo.date.locale");
+        dojo.require("dojo.date.stamp");
+        dojo.require("dojo.parser");
+    </script>
index 3d98e39..3644764 100644 (file)
@@ -29,9 +29,7 @@
     <div id='myopac_holds_thaw_date_form' class='hide_me'>
         <div id='myopac_holds_freeze_select_thaw'>&myopac.holds.freeze.select_thaw;</div>
         <p>
-            <input type='text' id='myopac_holds_thaw_date_input'/> 
-            <img src="<!--#echo var='OILS_OPAC_JS_HOST'-->/common/js/jscalendar/img.gif"  id='myopac_holds_thaw_date_img' class='cal_img'/>
-            (&opac.holds.freeze.thaw_date.format;)
+            <input dojoType="dijit.form.DateTextBox" size='10' maxlength='10' type='text' id='myopac_holds_thaw_date_input' /> 
         </p>
         <p>
             <button onclick='myopacApplyThawDate();'>&common.submit;</button>