From 9fcf8cdd09bf07ee046ee4f44ee5ab15557ebcfc Mon Sep 17 00:00:00 2001 From: Joseph Lewis Date: Wed, 3 Aug 2011 13:01:08 -0600 Subject: [PATCH] First bit of changing over from calendar.js to the dojo calendar. There are a few problems left to convert, and testing needs to be done too. Signed-off-by: Joseph Lewis --- Open-ILS/web/opac/common/js/strftime.js | 100 +++++++++++++++++++++ Open-ILS/web/reports/oils_rpt_common.xhtml | 3 +- Open-ILS/web/reports/oils_rpt_widget.js | 10 +++ Open-ILS/web/reports/xul/template-config.js | 34 ++++--- Open-ILS/web/reports/xul/template_builder.xul | 4 +- .../xul/staff_client/server/admin/cash_reports.js | 29 +----- .../staff_client/server/admin/cash_reports.xhtml | 33 +++---- .../xul/staff_client/server/admin/closed_dates.js | 46 ---------- .../staff_client/server/admin/closed_dates.xhtml | 38 ++++---- Open-ILS/xul/staff_client/server/main/data.xul | 7 +- Open-ILS/xul/staff_client/server/patron/ue.xhtml | 62 +++---------- 11 files changed, 172 insertions(+), 194 deletions(-) create mode 100644 Open-ILS/web/opac/common/js/strftime.js diff --git a/Open-ILS/web/opac/common/js/strftime.js b/Open-ILS/web/opac/common/js/strftime.js new file mode 100644 index 0000000000..c1ce22c142 --- /dev/null +++ b/Open-ILS/web/opac/common/js/strftime.js @@ -0,0 +1,100 @@ +/* + * strftime.js - A strftime implementation. + * + * Created by Joseph Lewis joehms22 at gmail dot com + * Copyright 2011 + * Licensed under the LGPL: http://www.gnu.org/licenses/lgpl.html + * + * + * This file includes contents taken from the Dynarch calendar: + * www.dynarch.com/projects/calendar, originally copyrighted by Mihai + * Bazon, and released under the GNU Lesser General Public License. + */ + + +/** Returns the number of the week in year, as defined in ISO 8601. */ +Date.prototype.getWeekNumber = function() { + var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0); + var DoW = d.getDay(); + d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu + var ms = d.valueOf(); // GMT + d.setMonth(0); + d.setDate(4); // Thu in Week 1 + return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1; +}; + +/** Returns the number of day in the year. */ +Date.prototype.getDayOfYear = function() { + var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0); + var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0); + var time = now - then; + return Math.floor(time / Date.DAY); +}; + +/** Prints the date in a string according to the given format. + See http://linux.die.net/man/3/strftime for formatting options, + note that all may not work in this implementation. + +*/ +function strftime (str, date) { + var m = date.getMonth(); + var d = date.getDate(); + var y = date.getFullYear(); + var wn = date.getWeekNumber(); + var w = date.getDay(); + var s = {}; + var hr = date.getHours(); + var pm = (hr >= 12); + var ir = (pm) ? (hr - 12) : hr; + var dy = date.getDayOfYear(); + if (ir == 0) + ir = 12; + var min = date.getMinutes(); + var sec = date.getSeconds(); + s["%a"] = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; //[FIXME: I18N] + s["%A"] = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; // full weekday name + s["%b"] = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; // abbreviated month name [FIXME: I18N] + s["%B"] = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; // full month name + s["%C"] = 1 + Math.floor(y / 100); // the century number + s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31) + s["%e"] = d; // the day of the month (range 1 to 31) + // FIXME: %D : american date style: %m/%d/%y + // FIXME: %E, %F, %G, %g, %h (man strftime) + s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format) + s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format) + s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366) + s["%k"] = hr; // hour, range 0 to 23 (24h format) + s["%l"] = ir; // hour, range 1 to 12 (12h format) + s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12 + s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59 + s["%n"] = "\n"; // a newline character + s["%p"] = pm ? "PM" : "AM"; + s["%P"] = pm ? "pm" : "am"; + // FIXME: %r : the time in am/pm notation %I:%M:%S %p + // FIXME: %R : the time in 24-hour notation %H:%M + s["%s"] = Math.floor(date.getTime() / 1000); + s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59 + s["%t"] = "\t"; // a tab character + // FIXME: %T : the time in 24-hour notation (%H:%M:%S) + s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn; + s["%u"] = w + 1; // the day of the week (range 1 to 7, 1 = MON) + s["%w"] = w; // the day of the week (range 0 to 6, 0 = SUN) + // FIXME: %x : preferred date representation for the current locale without the time + // FIXME: %X : preferred time representation for the current locale without the date + s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99) + s["%Y"] = y; // year with the century + s["%%"] = "%"; // a literal '%' character + + var re = /%./g; + + var a = str.match(re); + for (var i = 0; i < a.length; i++) { + var tmp = s[a[i]]; + if (tmp) { + re = new RegExp(a[i], 'g'); + str = str.replace(re, tmp); + } + } + + return str; +} diff --git a/Open-ILS/web/reports/oils_rpt_common.xhtml b/Open-ILS/web/reports/oils_rpt_common.xhtml index c1aad544c6..f26e8c2b4b 100644 --- a/Open-ILS/web/reports/oils_rpt_common.xhtml +++ b/Open-ILS/web/reports/oils_rpt_common.xhtml @@ -22,7 +22,7 @@ - + @@ -37,6 +37,7 @@ + - - + @@ -30,44 +30,31 @@ - - - - + + + - +
&staff.server.admin.cash.welcome;
+
&staff.server.admin.cash.start_date; - - + + &staff.server.admin.cash.end_date; - - + +
&staff.server.admin.cash.date_format;
diff --git a/Open-ILS/xul/staff_client/server/admin/closed_dates.js b/Open-ILS/xul/staff_client/server/admin/closed_dates.js index 09c78bbf47..5031c3cafc 100644 --- a/Open-ILS/xul/staff_client/server/admin/closed_dates.js +++ b/Open-ILS/xul/staff_client/server/admin/closed_dates.js @@ -29,8 +29,6 @@ function cdEditorInit() { cdAllDayTemplate = cdTbody.removeChild($('cd_allday_row')); cdAllMultiDayTemplate = cdTbody.removeChild($('cd_allmultiday_row')); - cdInitCals(); - fetchUser(); $('cd_user').appendChild(text(USER.usrname())); @@ -82,50 +80,6 @@ function cdBuildOrgs() { return gotoOrg; } -function cdInitCals() { - - Calendar.setup({ - inputField : "cd_edit_allday_start_date", - ifFormat : "%Y-%m-%d", - button : "cd_edit_allday_start_date_img", - align : "Tl", - singleClick : true - }); - - Calendar.setup({ - inputField : "cd_edit_allmultiday_start_date", - ifFormat : "%Y-%m-%d", - button : "cd_edit_allmultiday_start_date_img", - align : "Tl", - singleClick : true - }); - - Calendar.setup({ - inputField : "cd_edit_allmultiday_end_date", - ifFormat : "%Y-%m-%d", - button : "cd_edit_allmultiday_end_date_img", - align : "Tl", - singleClick : true - }); - - Calendar.setup({ - inputField : "cd_edit_end_date", - ifFormat : "%Y-%m-%d", - button : "cd_edit_end_date_img", - align : "Tl", - singleClick : true - }); - - Calendar.setup({ - inputField : "cd_edit_start_date", - ifFormat : "%Y-%m-%d", - button : "cd_edit_start_date_img", - align : "Tl", - singleClick : true - }); - - -} function cdDrawRange( start, end, alertSuccess ) { start = (start) ? start : new Date().getYear() + 1899 + '-01-01'; /* include last year's closed info for comparison */ diff --git a/Open-ILS/xul/staff_client/server/admin/closed_dates.xhtml b/Open-ILS/xul/staff_client/server/admin/closed_dates.xhtml index a3af761c2e..f38805cfa4 100644 --- a/Open-ILS/xul/staff_client/server/admin/closed_dates.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/closed_dates.xhtml @@ -7,6 +7,8 @@ ]> + + &staff.server.admin.closed_dates.title; @@ -25,11 +27,14 @@ - - - - + + + + + + @@ -39,7 +44,7 @@ - +
&staff.server.admin.closed_dates.welcome; @@ -130,9 +135,7 @@ - - + @@ -149,9 +152,7 @@ - - + @@ -176,9 +177,7 @@ &staff.server.admin.closed_dates.allday.label; - - + @@ -186,15 +185,10 @@ All Day From - - + Through - - - + diff --git a/Open-ILS/xul/staff_client/server/main/data.xul b/Open-ILS/xul/staff_client/server/main/data.xul index 3710dd7d2b..db86a23195 100644 --- a/Open-ILS/xul/staff_client/server/main/data.xul +++ b/Open-ILS/xul/staff_client/server/main/data.xul @@ -137,14 +137,9 @@ //cache_me('/xul/server/patron/ue_config.js','http'); //cache_me('/xul/server/patron/ue_ui.js','http'); //cache_me('/xul/server/patron/ue.js','http'); - //cache_me('/opac/common/js//config.js','http'); + //cache_me('/opac/common/js/config.js','http'); //cache_me('/opac/common/js/opac_utils.js','http'); //cache_me('/opac/common/js/init.js','http'); - //cache_me('/opac/common/js/jscalendar/calendar-brown.css','http'); - //cache_me('/opac/common/js/jscalendar/calendar.js','http'); - //cache_me('/opac/common/js/jscalendar/lang/calendar-en.js','http'); - //cache_me('/opac/common/js/jscalendar/calendar-setup.js','http'); - //cache_me('/opac/common/js/jscalendar/img.gif','http'); //cache_me('/xul/server/skin/media/images/stop_sign.png','http'); //cache_me('/xul/server/skin/media/images/bad_barcode.png','http'); diff --git a/Open-ILS/xul/staff_client/server/patron/ue.xhtml b/Open-ILS/xul/staff_client/server/patron/ue.xhtml index 37b807db2f..bda8555b1e 100644 --- a/Open-ILS/xul/staff_client/server/patron/ue.xhtml +++ b/Open-ILS/xul/staff_client/server/patron/ue.xhtml @@ -11,8 +11,14 @@ &ev.staff.patron.ue_xhtml.ev_user_editor.label; + + + + - + @@ -34,12 +40,6 @@ - - - - -