Example date in the Date Text Format selector in the prefs panel should use actual format

RESOLVED FIXED

Status

Calendar
Sunbird Only
--
minor
RESOLVED FIXED
16 years ago
12 years ago

People

(Reporter: gekacheka, Assigned: Mike Potter)

Tracking

Details

(Reporter)

Description

16 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2a) Gecko/20020910
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2a) Gecko/20020910

Possible regression of bug 164497

When calendar preference panel is first displayed, the date format is not
initialized to display the current date format.  The menuList drop down does
show formatted dates, so it is just the display that is not getting updated
after it is initialized.  

Reproducible: Always

Steps to Reproduce:
1. Edit | Preferences | Calendar

Actual Results:  
Date Text Format shows
"Long (ie, Apr 1, 2002)" or "Short Format (ie. 04/01/02)"


Expected Results:  
Date format shows an example date formatted using date formatter, which varies
depending on the users settings.  For egzample:
  "Long: Friday, 11 October 2002" or "Short: 2002-10-11"


--- Mozilla/chrome/calendar/content/pref/calendarPref.xul	Mon Sep  9 14:12:00 2002
+++ Mozilla/chrome/calendar/content/pref/calendarPref-fixed.xul	Fri Oct 11
20:04:33 2002
@@ -46,39 +46,12 @@
 ]>
 
 <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-     
onload="parent.initPanel('chrome://calendar/content/pref/calendarPref.xul');calendarPrefOnLoad()"
+     
onload="parent.initPanel('chrome://calendar/content/pref/calendarPref.xul');calendarPrefsOnLoad('&pref.dateformat.long;',
'&pref.dateformat.short;')"
       headertitle="&calendarPanel.label;">
 
+   <script type="application/x-javascript"
src="chrome://calendar/content/pref/calendarPref.js"/>
    <script type="application/x-javascript"
src="chrome://calendar/content/dateUtils.js"/>
    <script type="application/x-javascript"
src="chrome://global/content/strres.js"/>
-   
-   <script type="application/x-javascript">
-     <![CDATA[
-       function calendarPrefOnLoad()
-       {
-          var thisDateFormater = new DateFormater();
-             var Now = new Date();
-            var DateFormatLong = thisDateFormater.getLongFormatedDate( Now );
-            var DateFormatShort = thisDateFormater.getShortFormatedDate( Now );
-      
-            //set the menu items for the date format to their proper values.
-          
-            document.getElementById( "dateformat-long-menuitem" ).setAttribute(
"label", DateFormatLong );
-      
-            document.getElementById( "dateformat-short-menuitem"
).setAttribute( "label", DateFormatShort );
-          }
-      
-      /* 
-      ** NOTE: 
-      ** When you add a pref to this page, you have to add its ID to the
following list.
-      */
-       
-      var _elementIDs = [
-         "alarmplaysound", "alarmshow", "dateformat", "weekstarts",
"defaultlength", "defaultsnoozelength",
-         "reloadonlaunch", "categories"
-       ];
-     ]]>
-   </script>
 
    <groupbox align="start" orient="vertical">
       <caption label="&pref.mainbox.label;"/>
--- Mozilla/chrome/calendar/content/pref/calendarPref.js	Wed Sep  4 10:44:00 2002
+++ Mozilla/chrome/calendar/content/pref/calendarPref-fixed.js	Fri Oct 11
20:04:33 2002
@@ -34,19 +34,24 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
- function calendarPrefsInit()
- {
-    if( opener.gCalendarWindow )
-    {
-      var Now = new Date();
-      var DateFormatLong = gCalendarWindow.dateFormater.getLongFormatedDate( Now );
-      var DateFormatShort = gCalendarWindow.dateFormater.getShortFormatedDate(
Now );
-
-      //set the menu items for the date format to their proper values.
-    
-      document.getElementById( "dateformat-long-menuitem" ).setAttribute(
"label", DateFormatLong );
-
-      document.getElementById( "dateformat-short-menuitem" ).setAttribute(
"label", DateFormatShort );
-    }
-    
- }
+function calendarPrefsOnLoad(labelLong, labelShort)
+{
+  var now = new Date();
+  var dateFormatter = new DateFormater();
+  //
+  // create example dates using today's date
+  var dateFormattedLong = dateFormatter.getLongFormatedDate( now );
+  var dateFormattedShort = dateFormatter.getShortFormatedDate( now );
+  //
+  // menu items include examples of current date formats.
+  document.getElementById( "dateformat-long-menuitem" )
+    .setAttribute( "label", labelLong+": "+dateFormattedLong);
+  document.getElementById( "dateformat-short-menuitem" )
+    .setAttribute( "label", labelShort+": "+dateFormattedShort);
+  //
+  // deselect and reselect to update visible item title
+  var dateFormatMenuList = document.getElementById( "dateformat" );
+  var selectedIndex = dateFormatMenuList.selectedIndex;
+  dateFormatMenuList.selectedIndex = -1;
+  dateFormatMenuList.selectedIndex = selectedIndex;
+}
--- Mozilla/chrome/calendar/locale/en-US/calendarPrefs.dtd	Mon Sep  9 14:11:00 2002
+++ Mozilla/chrome/calendar/locale/en-US/calendarPrefs-fixed.dtd	Fri Oct 11
20:05:04 2002
@@ -45,8 +45,8 @@
 <!ENTITY pref.playasound  "Play a sound" >
 <!ENTITY pref.showalarmbox    "Show an alarm box" >
 <!ENTITY pref.dateformat.label      "Date Text Format:" >
-<!ENTITY pref.dateformat.long       "Long (ie. Apr 1, 2002)" >
-<!ENTITY pref.dateformat.short      "Short Format (ie. 04/01/02)"  >
+<!ENTITY pref.dateformat.long       "Long" >
+<!ENTITY pref.dateformat.short      "Short"  >
 <!ENTITY pref.defaultlength.label   "Default Event Length:" >
 <!ENTITY pref.defaultsnoozelength.label   "Default Snooze Length:" >
(Assignee)

Comment 1

16 years ago
I fixed this bug, but I didn't use the exact patch from this bug.
I see no reason to put the JS into a seperate file, its only 1 function.  I
think its fine where it is.
Also, you don't need to pass the text through to the function, you can get to it
easily if you set things up a bit differently.
See the calendarPref.xul file for what I did.
The patch did help though, I used the function to unset and then set the
selectedIndex to show the right value (seems like a XUL bug)
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → FIXED
The bugspam monkeys have been set free and are feeding on Calendar :: Sunbird Only. Be afraid for your sanity!
QA Contact: colint → sunbird
You need to log in before you can comment on or make changes to this bug.