Compare commits

..

1 Commits

Author SHA1 Message Date
Clemens Schwaighofer
6c1c528e2e Bug fix in Basic class, add method to basic class, flatpickr add
- Bug in date/time check in Basic class. Time check was invalid
- Add calcDaysInterval to get days between two dates plus weeki days
and weekend days
- Add flatpickr to replace datepickr and move datepickr init function
into separate file (from edit.*.js)
2019-06-07 16:11:28 +09:00
9 changed files with 166 additions and 43 deletions

View File

@@ -34,9 +34,20 @@
{/if}
{if $USE_PROTOTYPE}
<script src="{$js}/scriptaculous/prototype.js" type="text/javascript"></script>
{/if}
{if $USE_SCRIPTACULOUS}
{if $USE_SCRIPTACULOUS}
<script src="{$js}/scriptaculous/scriptaculous.js" type="text/javascript"></script>
{/if}
{/if}
{* for including datepickr or flatpickr *}
{if $JS_DATEPICKR}
<link rel=stylesheet type="text/css" href="{$js}/datepickr/datepickr.min.css">
<script language="JavaScript" src="{$js}/datepickr/datepickr.min.js"></script>
<script language="JavaScript" src="{$js}/datepickr/datepickr.init.js"></script>
{/if}
{if $JS_FLATPICKR}
<link rel=stylesheet type="text/css" href="{$js}/flatpickr/flatpickr.min.css">
<script language="JavaScript" src="{$js}/flatpickr/flatpickr.min.js"></script>
<script language="JavaScript" src="{$js}/flatpickr/flatpickr.ja.js"></script>
{/if}
{if $JAVASCRIPT}
<script language="JavaScript" src="{$js}{$JAVASCRIPT}"></script>

View File

@@ -26,10 +26,16 @@
{if $JAVASCRIPT}
<script language="JavaScript" src="{$js}{$JAVASCRIPT}"></script>
{/if}
{if $USE_JQUERY}
{* JQuery *}
<script type="text/javascript" src="{$js}/jquery.min.js"></script>
{/if}
{if $USE_PROTOTYPE}
{* declare prototype everywhere *}
<script src="{$js}/scriptaculous/prototype.js" type="text/javascript"></script>
{if $USE_SCRIPTACULOUS}
{if $USE_SCRIPTACULOUS}
<script src="{$js}/scriptaculous/scriptaculous.js" type="text/javascript"></script>
{/if}
{/if}
{if $JS_INCLUDE}
<script language="JavaScript" src="{$JS_INCLUDE}"></script>
@@ -37,10 +43,16 @@
{if $JS_SPECIAL_INCLUDE}
<script language="JavaScript" src="{$JS_SPECIAL_INCLUDE}"></script>
{/if}
{* for including datepickr *}
{* for including datepickr or flatpickr *}
{if $JS_DATEPICKR}
<link rel=stylesheet type="text/css" href="{$js}/datepickr/datepickr.min.css">
<script language="JavaScript" src="{$js}/datepickr/datepickr.min.js"></script>
<script language="JavaScript" src="{$js}/datepickr/datepickr.init.js"></script>
{/if}
{if $JS_FLATPICKR}
<link rel=stylesheet type="text/css" href="{$js}/flatpickr/flatpickr.min.css">
<script language="JavaScript" src="{$js}/flatpickr/flatpickr.min.js"></script>
<script language="JavaScript" src="{$js}/flatpickr/flatpickr.ja.js"></script>
{/if}
{if $USE_OVERLIB}
{popup_init src="`$js`/overlib/overlib.js"}

View File

@@ -0,0 +1,20 @@
/* only used for datepickr */
// METHOD: initDatepickr
// PARAMS: initial date ID (#)
// RETURN: true on ok, false on failure
// DESC : inits date pickr which translations for dates (week/month)
function initDatepickr(init_date)
{
if ($(init_date)) {
datepickr('#' + init_date); // we need to add this so we have it initialized before we can actually change the definitions
// dates in japanese
datepickr.prototype.l10n.months.shorthand = [__('Jan'), __('Feb'), __('Mar'), __('Apr'), __('May'), __('Jun'), __('Jul'), __('Aug'), __('Sep'), __('Oct'), __('Nov'), __('Dec')];
datepickr.prototype.l10n.months.longhand = [__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December')];
datepickr.prototype.l10n.weekdays.shorthand = [__('Mon'), __('Tue'), __('Wed'), __('Thu'), __('Fri'), __('Sat'), __('Sun')];
datepickr.prototype.l10n.weekdays.longhand = [__('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday'), __('Sunday')];
return true;
} else {
return false;
}
}

View File

@@ -659,25 +659,6 @@ function html_options_refill(name, data, sort = '')
}
}
// METHOD: initDatepickr
// PARAMS: initial date ID (#)
// RETURN: true on ok, false on failure
// DESC : inits date pickr which translations for dates (week/month)
function initDatepickr(init_date)
{
if (document.getElementById(init_date)) {
datepickr('#' + init_date); // we need to add this so we have it initialized before we can actually change the definitions
// dates in japanese
datepickr.prototype.l10n.months.shorthand = [__('Jan'), __('Feb'), __('Mar'), __('Apr'), __('May'), __('Jun'), __('Jul'), __('Aug'), __('Sep'), __('Oct'), __('Nov'), __('Dec')];
datepickr.prototype.l10n.months.longhand = [__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December')];
datepickr.prototype.l10n.weekdays.shorthand = [__('Mon'), __('Tue'), __('Wed'), __('Thu'), __('Fri'), __('Sat'), __('Sun')];
datepickr.prototype.l10n.weekdays.longhand = [__('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday'), __('Sunday')];
return true;
} else {
return false;
}
}
// *** MASTER logout call
// METHOD: loginLogout
// PARAMS: none

View File

@@ -737,25 +737,6 @@ function html_options_refill(name, data, sort = '')
}
}
// METHOD: initDatepickr
// PARAMS: initial date ID (#)
// RETURN: true on ok, false on failure
// DESC : inits date pickr which translations for dates (week/month)
function initDatepickr(init_date)
{
if ($(init_date)) {
datepickr('#' + init_date); // we need to add this so we have it initialized before we can actually change the definitions
// dates in japanese
datepickr.prototype.l10n.months.shorthand = [__('Jan'), __('Feb'), __('Mar'), __('Apr'), __('May'), __('Jun'), __('Jul'), __('Aug'), __('Sep'), __('Oct'), __('Nov'), __('Dec')];
datepickr.prototype.l10n.months.longhand = [__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December')];
datepickr.prototype.l10n.weekdays.shorthand = [__('Mon'), __('Tue'), __('Wed'), __('Thu'), __('Fri'), __('Sat'), __('Sun')];
datepickr.prototype.l10n.weekdays.longhand = [__('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday'), __('Sunday')];
return true;
} else {
return false;
}
}
// *** MASTER logout call
// METHOD: loginLogout
// PARAMS: none

View File

@@ -0,0 +1,66 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.ja = {}));
}(this, function (exports) { 'use strict';
var fp = typeof window !== "undefined" && window.flatpickr !== undefined
? window.flatpickr
: {
l10ns: {}
};
var Japanese = {
weekdays: {
shorthand: ["日", "月", "火", "水", "木", "金", "土"],
longhand: [
"日曜日",
"月曜日",
"火曜日",
"水曜日",
"木曜日",
"金曜日",
"土曜日",
]
},
months: {
shorthand: [
"1月",
"2月",
"3月",
"4月",
"5月",
"6月",
"7月",
"8月",
"9月",
"10月",
"11月",
"12月",
],
longhand: [
"1月",
"2月",
"3月",
"4月",
"5月",
"6月",
"7月",
"8月",
"9月",
"10月",
"11月",
"12月",
]
},
time_24hr: true,
rangeSeparator: ' から '
};
fp.l10ns.ja = Japanese;
var ja = fp.l10ns;
exports.Japanese = Japanese;
exports.default = ja;
Object.defineProperty(exports, '__esModule', { value: true });
}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1374,7 +1374,10 @@ class Basic
if (!$hour || !$min) {
return false;
}
if (($hour < 0 && $hour > 24) || ($min < 0 && $hour > 60) || ($sec && $sec < 0 && $sec > 60)) {
if (($hour < 0 || $hour > 24) ||
($min < 0 || $hour > 60) ||
($sec && ($sec < 0 || $sec > 60))
) {
return false;
}
return true;
@@ -1446,6 +1449,40 @@ class Basic
}
}
// METHOD: calcDaysInterval
// PARAMS: start date, end date
// RETURN: overall days, week days, weekend days as array 0...2 or named
// DESC : calculates the days between two dates
private function calcDaysInterval($start_date, $end_date, $return_named = false)
{
// pos 0 all, pos 1 weekday, pos 2 weekend
$days = array ();
$start = new \DateTime($start_date);
$end = new \DateTime($end_date);
$days[0] = $end->diff($start)->days;
$period = new \DatePeriod($start, new \DateInterval('P1D'), $end);
foreach ($period as $dt) {
$curr = $dt->format('D');
if ($curr == 'Sat' || $curr == 'Sun') {
$days[2] ++;
} else {
$days[1] ++;
}
}
if ($return_named === true) {
return array (
'overall' => $days[0],
'weekday' => $days[1],
'weekend' => $days[2]
);
} else {
return $days;
}
}
// METHOD: createThumbnail
// WAS : CreateThumbnail
// PARAMS: pic -> picture where from we create a thumbnail