[Rt-commit] r3462 - in rt/branches/3.5-TESTING: . html html/Elements html/Helpers html/NoAuth/css html/NoAuth/js

trs at bestpractical.com trs at bestpractical.com
Mon Jul 11 20:05:47 EDT 2005


Author: trs
Date: Mon Jul 11 20:05:47 2005
New Revision: 3462

Added:
   rt/branches/3.5-TESTING/html/Helpers/
   rt/branches/3.5-TESTING/html/Helpers/CalPopup.html
Removed:
   rt/branches/3.5-TESTING/html/CalPopup.html
Modified:
   rt/branches/3.5-TESTING/   (props changed)
   rt/branches/3.5-TESTING/html/Elements/SelectDate
   rt/branches/3.5-TESTING/html/NoAuth/css/misc.css
   rt/branches/3.5-TESTING/html/NoAuth/js/util.js
Log:
 r4983 at wintermute:  tom | 2005-07-11 20:02:25 -0400
 Moved CalPopup.html around and reworked it from the HTML to the CSS to the JS to the UI wording.


Modified: rt/branches/3.5-TESTING/html/Elements/SelectDate
==============================================================================
--- rt/branches/3.5-TESTING/html/Elements/SelectDate	(original)
+++ rt/branches/3.5-TESTING/html/Elements/SelectDate	Mon Jul 11 20:05:47 2005
@@ -43,15 +43,10 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
-<input type="text" id="<% $Name %>" name="<% $Name %>" value="<% $Default %>" size="<% $Size %>"> 
-<script language="javascript" type="text/javascript">
-<!--
-document.write('<a href="javascript:');
-document.write("openCalWindow('<% $Name %>');");
-document.write('">pick</a>');
-// -->
-</script>
-
+<script type="text/javascript"><!--
+    onLoadHook('createCalendarLink("<% $Name %>");');
+--></script>
+<input type="text" id="<% $Name %>" name="<% $Name %>" value="<% $Default %>" size="<% $Size %>" />
 <%init>
 unless ((defined $Default) or 
 	($current <= 0)) {

Added: rt/branches/3.5-TESTING/html/Helpers/CalPopup.html
==============================================================================
--- (empty file)
+++ rt/branches/3.5-TESTING/html/Helpers/CalPopup.html	Mon Jul 11 20:05:47 2005
@@ -0,0 +1,78 @@
+<& /Elements/Header, ShowBar => 0 &>
+%# From /Elements/Header
+</div>
+<div id="body">
+
+<a href="#" onclick="window.close(); return false;"><&|/l&>Close window</&></a>
+
+<div class="calendar">
+  <table>
+    <caption>
+      <a class="prev" href="CalPopup.html?DisplayedMonth=<%$prev_month%>&DisplayedYear=<%$prev_year%>&field=<%$field%>"><&|/l&>Prev</&></a>
+      <span class="month"><% $months[$DisplayedMonth] %> <% $DisplayedYear %></span>
+      <a class="next" href="CalPopup.html?DisplayedMonth=<%$next_month%>&DisplayedYear=<%$next_year%>&field=<%$field%>"><&|/l&>Next</&></a>
+    </caption>
+    <tr>
+% foreach my $wday (@weekdays) {
+      <th><%$wday%></th>
+% }
+    </tr>
+% foreach my $week (@cal) {
+    <tr>
+%     foreach my $day (@{$week}) {
+      <td>
+%         if ($day) {
+%             my $datestr = sprintf('%04d-%02d-%02d', $DisplayedYear, $DisplayedMonth+1, $day);
+        <a href="#" onclick="updateParentField('<% $field %>','<% $datestr %>'); return false;"><% $day %></a>
+%         } else {
+        &nbsp;
+%         }
+      </td>
+%     } #foreach $day
+    </tr>
+% } # foreach $week
+  </table>
+</div>
+
+<%init>
+use Calendar::Simple;
+my @today = localtime(time());
+
+my @weekdays;
+push @weekdays, loc($_)
+  for qw(Sun Mon Tue Wed Thu Fri Sat);
+
+my @months;
+push @months, loc($_)
+  for qw(January February March April May June July August
+         September October November December);
+
+unless ($DisplayedYear) {
+    $DisplayedMonth = $today[4];
+    $DisplayedYear  = ($today[5] + 1900);
+}              
+
+my ($prev_year, $next_year, $prev_month, $next_month);
+$prev_month = $next_month = $DisplayedMonth;
+$prev_year  = $next_year  = $DisplayedYear;
+
+$next_month++;
+$prev_month--;
+
+if ($DisplayedMonth == 11) {
+    $next_year++;
+    $next_month = 0;
+}
+elsif ($DisplayedMonth == 0) {
+    $prev_month = 11;
+    $prev_year--;
+}
+
+my @cal = calendar($DisplayedMonth, $DisplayedYear);
+</%init>
+
+<%args>
+$field => 'none'
+$DisplayedMonth => undef
+$DisplayedYear => undef
+</%args>

Modified: rt/branches/3.5-TESTING/html/NoAuth/css/misc.css
==============================================================================
--- rt/branches/3.5-TESTING/html/NoAuth/css/misc.css	(original)
+++ rt/branches/3.5-TESTING/html/NoAuth/css/misc.css	Mon Jul 11 20:05:47 2005
@@ -152,3 +152,14 @@
 
 .hide, .hidden { display: none !important; }
 
+.calendar {
+    text-align: center;
+    margin: 2em auto 0 auto;
+}
+
+.calendar td, .calendar th { padding: 0.1em 0.25em 0.1em 0.25em; }
+
+.calendar caption .month {
+    padding: 0 1em 0 1em;
+    font-size: 1.5em;
+}

Modified: rt/branches/3.5-TESTING/html/NoAuth/js/util.js
==============================================================================
--- rt/branches/3.5-TESTING/html/NoAuth/js/util.js	(original)
+++ rt/branches/3.5-TESTING/html/NoAuth/js/util.js	Mon Jul 11 20:05:47 2005
@@ -67,7 +67,7 @@
 }
 
 function openCalWindow(field) {
-    var objWindow = window.open('<%$RT::WebPath%>/CalPopup.html?field='+field, 'Pick', 'height=400,width=400,scrollbars=1');
+    var objWindow = window.open('<%$RT::WebPath%>/Helpers/CalPopup.html?field='+field, '<% loc("Choose a date") %>', 'height=400,width=400,scrollbars=1');
     objWindow.focus();
 }
 
@@ -78,6 +78,26 @@
     }
 }
 
+function createCalendarLink(input) {
+    var e = document.getElementById(input);
+    if (e) {
+        var link = document.createElement('a');
+        link.setAttribute('href', '#');
+        link.setAttribute('onclick', "openCalWindow('"+input+"'); return false;");
+        
+        var text = document.createTextNode('<% loc("Choose a date") %>');
+        link.appendChild(text);
+        
+        var space = document.createTextNode(' ');
+        
+        e.parentNode.insertBefore(link, e.nextSibling);
+        e.parentNode.insertBefore(space, e.nextSibling);
+        
+        return true;
+    }
+    return false;
+}
+
 // onload handlers
 
 var onLoadStack     = new Array();


More information about the Rt-commit mailing list