← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15027: renamed Buddhist calendar => Thai calendar. Include js calendars conditionally. Make system calen...

 

------------------------------------------------------------
revno: 15027
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-27 21:10:11 +0545
message:
  renamed Buddhist calendar => Thai calendar. Include js calendars conditionally. Make system calendar available as dhis2.period.calendar.
removed:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/BuddhistCalendar.java
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/ThaiCalendar.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.thai.min.js
modified:
  dhis-2/dhis-services/dhis-service-i18n/src/main/resources/i18n_global.properties
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/BuddhistCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/BuddhistCalendar.java	2014-04-25 12:25:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/BuddhistCalendar.java	1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
-package org.hisp.dhis.calendar.impl;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.calendar.ChronologyBasedCalendar;
-import org.joda.time.chrono.BuddhistChronology;
-import org.springframework.stereotype.Component;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@Component
-public class BuddhistCalendar extends ChronologyBasedCalendar
-{
-    private static final Calendar self = new BuddhistCalendar();
-
-    public static Calendar getInstance()
-    {
-        return self;
-    }
-
-    protected BuddhistCalendar()
-    {
-        super( BuddhistChronology.getInstance() );
-    }
-
-    @Override
-    public String name()
-    {
-        return "buddhist";
-    }
-}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/ThaiCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/ThaiCalendar.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/ThaiCalendar.java	2014-04-27 15:25:11 +0000
@@ -0,0 +1,59 @@
+package org.hisp.dhis.calendar.impl;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.calendar.Calendar;
+import org.hisp.dhis.calendar.ChronologyBasedCalendar;
+import org.joda.time.chrono.BuddhistChronology;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Component
+public class ThaiCalendar extends ChronologyBasedCalendar
+{
+    private static final Calendar self = new ThaiCalendar();
+
+    public static Calendar getInstance()
+    {
+        return self;
+    }
+
+    protected ThaiCalendar()
+    {
+        super( BuddhistChronology.getInstance() );
+    }
+
+    @Override
+    public String name()
+    {
+        return "thai";
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-i18n/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-services/dhis-service-i18n/src/main/resources/i18n_global.properties	2014-04-27 15:06:06 +0000
+++ dhis-2/dhis-services/dhis-service-i18n/src/main/resources/i18n_global.properties	2014-04-27 15:25:11 +0000
@@ -836,6 +836,6 @@
 julian=Julian
 gregorian=Gregorian
 ethiopian=Ethiopian
-buddhist=Buddhist (Thai)
+thai=Thai
 iso8601=ISO 8601
 coptic=Coptic

=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.thai.min.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.thai.min.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.thai.min.js	2014-04-27 15:25:11 +0000
@@ -0,0 +1,6 @@
+/* http://keith-wood.name/calendars.html
+   Thai calendar for jQuery v1.2.1.
+   Written by Keith Wood (kbwood{at}iinet.com.au) February 2010.
+   Available under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license. 
+   Please attribute the author if you use it. */
+(function($){var e=$.calendars.instance();function ThaiCalendar(a){this.local=this.regional[a||'']||this.regional['']}ThaiCalendar.prototype=new $.calendars.baseCalendar;$.extend(ThaiCalendar.prototype,{name:'Thai',jdEpoch:1523098.5,yearsOffset:543,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:false,minMonth:1,firstMonth:1,minDay:1,regional:{'':{name:'Thai',epochs:['BBE','BE'],monthNames:['January','February','March','April','May','June','July','August','September','October','November','December'],monthNamesShort:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],dayNames:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],dayNamesShort:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],dayNamesMin:['Su','Mo','Tu','We','Th','Fr','Sa'],dateFormat:'dd/mm/yyyy',firstDay:0,isRTL:false}},leapYear:function(a){var b=this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear);var a=this._t2gYear(b.year());return e.leapYear(a)},weekOfYear:function(a,b,c){var d=this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear);var a=this._t2gYear(d.year());return e.weekOfYear(a,d.month(),d.day())},daysInMonth:function(a,b){var c=this._validate(a,b,this.minDay,$.calendars.local.invalidMonth);return this.daysPerMonth[c.month()-1]+(c.month()==2&&this.leapYear(c.year())?1:0)},weekDay:function(a,b,c){return(this.dayOfWeek(a,b,c)||7)<6},toJD:function(a,b,c){var d=this._validate(a,b,c,$.calendars.local.invalidDate);var a=this._t2gYear(d.year());return e.toJD(a,d.month(),d.day())},fromJD:function(a){var b=e.fromJD(a);var c=this._g2tYear(b.year());return this.newDate(c,b.month(),b.day())},_t2gYear:function(a){return a-this.yearsOffset-(a>=1&&a<=this.yearsOffset?1:0)},_g2tYear:function(a){return a+this.yearsOffset+(a>=-this.yearsOffset&&a<=-1?1:0)}});$.calendars.calendars.thai=ThaiCalendar})(jQuery);
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm	2014-04-27 14:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm	2014-04-27 15:25:11 +0000
@@ -56,11 +56,11 @@
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.select.js?_rev=$!{buildRevision}"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.min.js?_rev=$!{buildRevision}"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.plus.min.js?_rev=$!{buildRevision}"></script>
-    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.coptic.min.js?_rev=$!{buildRevision}"></script>
-    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.ethiopian.min.js?_rev=$!{buildRevision}"></script>
-    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.islamic.min.js?_rev=$!{buildRevision}"></script>
-    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.julian.min.js?_rev=$!{buildRevision}"></script>
-    <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.nepali.min.js?_rev=$!{buildRevision}"></script>
+
+    #if( $keyCalendar == "coptic" || $keyCalendar == "ethiopian" || $keyCalendar == "islamic"  || $keyCalendar == "julian" || $keyCalendar == "nepali" || $keyCalendar == "thai" )
+      <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendar/jquery.calendars.${keyCalendar}.min.js?_rev=$!{buildRevision}"></script>
+    #end
+
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.period.js?_rev=$!{buildRevision}"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.selected.js?_rev=$!{buildRevision}"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.comparator.js?_rev=$!{buildRevision}"></script>
@@ -83,6 +83,14 @@
     #foreach( $javascript in $javascripts )
     <script type="text/javascript" src="${javascript}?_rev=$!{buildRevision}"></script>
     #end
+    <!-- Create global system calendar -->
+    <script>
+      #if( $keyCalendar == 'iso8601')
+      dhis2.period.calendar = $.calendars.instance('gregorian');
+      #else
+      dhis2.period.calendar = $.calendars.instance('$keyCalendar');
+      #end
+    </script>
   </head>
 
   <body>